-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbd469d
commit 88162af
Showing
4 changed files
with
105 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,84 @@ | ||
discard """ | ||
cmd: "nim $target --hints:on -d:testing -d:ssl --nimblePath:tests/deps $options $file" | ||
""" | ||
import std/[asyncdispatch, options, sequtils, strutils, sugar] | ||
import api/[cfclient, cfcore] | ||
import ../tutils | ||
|
||
import asyncdispatch, options, sequtils, strutils, sugar | ||
import api/cfclient, api/cfcore | ||
|
||
block: # fetch by query | ||
let mods = waitFor(fetchAddonsByQuery("jei")) | ||
asyncBlock: # fetch by query | ||
let mods = await fetchAddonsByQuery("jei") | ||
doAssert mods[0].projectId == 238222 | ||
doAssert mods[0].name == "Just Enough Items (JEI)" | ||
|
||
block: # fetch mods by query | ||
let mods = waitFor(fetchAddonsByQuery("jei", some(CfAddonGameCategory.Mod))) | ||
asyncBlock: # fetch mods by query | ||
let mods = await fetchAddonsByQuery("jei", some(CfAddonGameCategory.Mod)) | ||
doAssert mods.all(m => m.websiteUrl.contains("/mc-mods/")) | ||
|
||
block: # fetch resource packs by query | ||
let mods = waitFor(fetchAddonsByQuery("jei", some(CfAddonGameCategory.Resourcepack))) | ||
asyncBlock: # fetch resource packs by query | ||
let mods = await fetchAddonsByQuery("jei", some(CfAddonGameCategory.Resourcepack)) | ||
doAssert mods.all(m => m.websiteUrl.contains("/texture-packs/")) | ||
|
||
block: # fetch mod by id | ||
let mcMod = waitFor(fetchAddon(220318)).get() | ||
asyncBlock: # fetch non-existing by query | ||
let mods = await fetchAddonsByQuery("---------------------------") | ||
doAssert mods.len == 0 | ||
|
||
asyncBlock: # fetch mod by id | ||
let mcMod = await fetchAddon(220318) | ||
doAssert mcMod.projectId == 220318 | ||
doAssert mcMod.name == "Biomes O' Plenty" | ||
|
||
## Skip failing test because the curse.nikky.moe api doesn't update anymore | ||
#[ | ||
block: # fetch mod by slug | ||
var mcMod = waitFor(fetchAddon("appleskin")).get() | ||
asyncBlock: # fetch mod by non-existing id | ||
doAssertRaises(CfClientError): | ||
discard await fetchAddon(99999999) | ||
|
||
asyncBlock: # fetch mods by id | ||
let mcMods = await fetchAddons(@[220318, 238222]) | ||
doAssert mcMods.any((x) => x.projectId == 220318) | ||
doAssert mcMods.any((x) => x.projectId == 238222) | ||
|
||
asyncBlock: # fetch mods by non-existing id | ||
doAssertRaises(CfClientError): | ||
discard await fetchAddons(@[220318, 99999999]) | ||
|
||
asyncBlock: # fetch mod by slug | ||
var mcMod = await fetchAddon("appleskin") | ||
doAssert mcMod.projectId == 248787 | ||
mcMod = waitFor(fetchAddon("dtbop")).get() | ||
mcMod = await fetchAddon("dtbop") | ||
doAssert mcMod.projectId == 289529 | ||
mcMod = waitFor(fetchAddon("dtphc")).get() | ||
mcMod = await fetchAddon("dtphc") | ||
doAssert mcMod.projectId == 307560 | ||
]# | ||
|
||
block: # fetch mod files | ||
let modFiles = waitFor(fetchAddonFiles(248787)) | ||
asyncBlock: # fetch mod by non-existing slug | ||
doAssertRaises(CfClientError): | ||
discard await fetchAddon("abcdefghijklmnopqrstuvwxyz") | ||
|
||
asyncBlock: # fetch mod files by project id | ||
let modFiles = await fetchAddonFiles(248787) | ||
doAssert modFiles.any((x) => x.fileId == 3035787) | ||
|
||
block: # fetch mod file | ||
let modFile = waitFor(fetchAddonFile(306770, 2992184)).get() | ||
asyncBlock: # fetch mod files by non-existing project id | ||
doAssertRaises(CfClientError): | ||
discard await fetchAddonFiles(99999999) | ||
|
||
asyncBlock: # fetch mod files by file ids | ||
let modFiles = await fetchAddonFiles(@[2992184, 3098571]) | ||
doAssert modFiles.any((x) => x.fileId == 2992184) | ||
doAssert modFiles.any((x) => x.fileId == 3098571) | ||
|
||
asyncBlock: # fetch mod files by non-existing file ids | ||
doAssertRaises(CfClientError): | ||
discard await fetchAddonFiles(@[2992184, 99999999]) | ||
|
||
asyncBlock: # fetch mod file by project & file id | ||
let modFile = await fetchAddonFile(306770, 2992184) | ||
doAssert modFile.fileId == 2992184 | ||
doAssert modFile.name == "Patchouli-1.0-21.jar" | ||
|
||
block: # check if dependencies are tracked | ||
let modFile = waitFor(fetchAddonFile(243121, 3366626)).get() | ||
asyncBlock: # fetch mod files by non-existing project & file id | ||
doAssertRaises(CfClientError): | ||
discard await fetchAddonFile(306770, 99999999) | ||
doAssertRaises(CfClientError): | ||
discard await fetchAddonFile(99999999, 2992184) | ||
|
||
asyncBlock: # check if dependencies are tracked | ||
let modFile = await fetchAddonFile(243121, 3366626) | ||
doAssert modFile.dependencies == @[250363] | ||
|
||
runTests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
--path:"../src/" | ||
--path:"../src/" | ||
-d:ssl |