Skip to content

Commit

Permalink
add avpr top level api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
caroott committed Mar 22, 2024
1 parent 11005ca commit 508456f
Showing 1 changed file with 78 additions and 34 deletions.
112 changes: 78 additions & 34 deletions tests/ARCValidationPackages.Tests/TopLevelAPITests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,98 @@ open AVPRIndex.Domain
[<Tests>]
let ``Toplevel API tests`` =
testSequenced (testList "Toplevel API tests" [
testSequenced (testList "Toplevel github API tests" [

test "getSyncedConfigAndCache returns OK" {
resetConfigEnvironment()
let syncResult = API.GetSyncedConfigAndCache(false, ?Token = get_gh_api_token())
Expect.isOk (syncResult) "updateIndex did not return OK"
}
test "getSyncedConfigAndCache returns OK" {
resetConfigEnvironment()
let syncResult = API.GetSyncedConfigAndCache(false, ?Token = get_gh_api_token())
Expect.isOk (syncResult) "updateIndex did not return OK"
}

testSequenced (testList "getSyncedConfigAndCache" [
testSequenced (testList "getSyncedConfigAndCache" [

yield! testFixture (Fixtures.withFreshConfigAndCachePreview (get_gh_api_token())) [
"Fresh config filepath",
fun (freshConfig, _) ->
Expect.equal freshConfig.ConfigFilePath expected_config_file_path "config file path is not correct"
yield! testFixture (Fixtures.withFreshConfigAndCachePreview (get_gh_api_token())) [
"Fresh config filepath",
fun (freshConfig, _) ->
Expect.equal freshConfig.ConfigFilePath expected_config_file_path "config file path is not correct"

"Fresh package cache preview folder",
fun (freshConfig, _) ->
Expect.equal freshConfig.PackageCacheFolderPreview expected_package_cache_folder_path_preview "package cache preview folder path is not correct"
"Fresh package cache preview folder",
fun (freshConfig, _) ->
Expect.equal freshConfig.PackageCacheFolderPreview expected_package_cache_folder_path_preview "package cache preview folder path is not correct"


"Fresh package cache release folder",
fun (freshConfig, _) ->
Expect.equal freshConfig.PackageCacheFolderRelease expected_package_cache_folder_path_release "package cache release folder path is not correct"
"Fresh package cache release folder",
fun (freshConfig, _) ->
Expect.equal freshConfig.PackageCacheFolderRelease expected_package_cache_folder_path_release "package cache release folder path is not correct"


"Fresh config package index contains packages",
fun (freshConfig, _) ->
Expect.isGreaterThan freshConfig.PackageIndex.Length 0 "fresh config package index was empty"
"Fresh config package index contains packages",
fun (freshConfig, _) ->
Expect.isGreaterThan freshConfig.PackageIndex.Length 0 "fresh config package index was empty"

"Fresh config package index contains test package",
fun (freshConfig, _) ->
Expect.isTrue (Array.exists (fun (x:ValidationPackageIndex) -> x.Metadata.Name = "test") freshConfig.PackageIndex) "fresh config package index was empty"
"Fresh package cache is empty",
"Fresh config package index contains test package",
fun (freshConfig, _) ->
Expect.isTrue (Array.exists (fun (x:ValidationPackageIndex) -> x.Metadata.Name = "test") freshConfig.PackageIndex) "fresh config package index was empty"
"Fresh package cache is empty",

fun (_, freshCache) ->
Expect.equal freshCache.Count 0 "fresh cache was not empty"
]
fun (_, freshCache) ->
Expect.equal freshCache.Count 0 "fresh cache was not empty"
]

])
])

testSequenced (testList "updateIndex" [
yield! testFixture (Fixtures.withFreshConfigAndCachePreview (get_gh_api_token())) [
"updateIndex returns OK",
fun (freshConfig, _) ->
Expect.isOk (API.UpdateIndex(freshConfig, ?Token = get_gh_api_token())) "updateIndex did not return OK"
]
])

testSequenced (testList "updateIndex" [
yield! testFixture (Fixtures.withFreshConfigAndCachePreview (get_gh_api_token())) [
"updateIndex returns OK",
fun (freshConfig, _) ->
Expect.isOk (API.UpdateIndex(freshConfig, ?Token = get_gh_api_token())) "updateIndex did not return OK"
]
testSequenced (testList "saveAndCachePackage" [

])
])
testSequenced (testList "Toplevel AVPR API tests" [

test "getSyncedConfigAndCache returns OK" {
resetConfigEnvironment()
let syncResult = API.GetSyncedConfigAndCache(true)
Expect.isOk (syncResult) "updateIndex did not return OK"
}

testSequenced (testList "getSyncedConfigAndCache" [

yield! testFixture (Fixtures.withFreshConfigAndCachePreview (get_gh_api_token())) [
"Fresh config filepath",
fun (freshConfig, _) ->
Expect.equal freshConfig.ConfigFilePath expected_config_file_path "config file path is not correct"

"Fresh package cache preview folder",
fun (freshConfig, _) ->
Expect.equal freshConfig.PackageCacheFolderPreview expected_package_cache_folder_path_preview "package cache preview folder path is not correct"

"Fresh package cache release folder",
fun (freshConfig, _) ->
Expect.equal freshConfig.PackageCacheFolderRelease expected_package_cache_folder_path_release "package cache release folder path is not correct"

"Fresh config package index contains packages",
fun (freshConfig, _) ->
Expect.isGreaterThan freshConfig.PackageIndex.Length 0 "fresh config package index was empty"

"Fresh config package index contains test package",
fun (freshConfig, _) ->
Expect.isTrue (Array.exists (fun (x:ValidationPackageIndex) -> x.Metadata.Name = "test") freshConfig.PackageIndex) "fresh config package index was empty"
"Fresh package cache is empty",

fun (_, freshCache) ->
Expect.equal freshCache.Count 0 "fresh cache was not empty"
]

])

testSequenced (testList "saveAndCachePackage" [
testSequenced (testList "saveAndCachePackage" [

])
])
])

0 comments on commit 508456f

Please sign in to comment.