Implemented GET on /projects/<proj-id> and started unit tests.
This commit is contained in:
@ -79,7 +79,7 @@ proc getOrFail(n: JsonNode, key: string, objName: string = ""): JsonNode =
|
||||
return n[key]
|
||||
|
||||
# Configuration parsing code
|
||||
|
||||
|
||||
proc parseProjectDef*(pJson: JsonNode): ProjectDef =
|
||||
var envVars = newStringTable(modeCaseSensitive)
|
||||
for k, v in pJson.getIfExists("envVars").getFields: envVars[k] = v.getStr("")
|
||||
@ -186,13 +186,28 @@ proc `%`*(req: RunRequest): JsonNode =
|
||||
"workspaceDir": req.workspaceDir,
|
||||
"forceRebuild": req.forceRebuild }
|
||||
|
||||
proc `%`*(user: User): JsonNode =
|
||||
result = %* {
|
||||
"name": user.name,
|
||||
"hashedPwd": user.hashedPwd }
|
||||
|
||||
proc `%`*(cfg: StrawBossConfig): JsonNode =
|
||||
result = %* {
|
||||
"artifactsRepo": cfg.artifactsRepo,
|
||||
"authSecret": cfg.authSecret,
|
||||
"debug": cfg.debug,
|
||||
"projects": %cfg.projects,
|
||||
"pwdCost": cfg.pwdCost,
|
||||
"users": %cfg.users }
|
||||
|
||||
proc `$`*(s: BuildStatus): string = result = pretty(%s)
|
||||
proc `$`*(req: RunRequest): string = result = pretty(%req)
|
||||
proc `$`*(pd: ProjectDef): string = result = pretty(%pd)
|
||||
proc `$`*(cfg: StrawBossConfig): string = result = pretty(%cfg)
|
||||
|
||||
# TODO: maybe a macro for more general-purpose, shallow object comparison?
|
||||
#proc `==`*(a, b: ProjectDef): bool =
|
||||
|
||||
|
||||
template shallowEquals(a, b: RootObj): bool =
|
||||
if type(a) != type(b): return false
|
||||
var anyB = toAny(b)
|
||||
|
Reference in New Issue
Block a user