Skip to content

Commit

Permalink
TEST: refactor and use json expectation
Browse files Browse the repository at this point in the history
  • Loading branch information
hdurand0710 committed Jan 25, 2024
1 parent 1120936 commit fba3af8
Show file tree
Hide file tree
Showing 83 changed files with 9,172 additions and 9,818 deletions.
6 changes: 3 additions & 3 deletions configuration/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ func (c *client) CreateACL(parentType string, parentName string, data *models.AC

func (c *client) getACLParserFromParent(parent string) (parser.Section, error) {
switch parent {
case "backend":
case BackendParentName:
return parser.Backends, nil
case "frontend":
case FrontendParentName:
return parser.Frontends, nil
case "fcgi-app":
case FCGIAppParentName:
return parser.FCGIApp, nil
default:
return "", fmt.Errorf("unsupported parent: %s", parent)
Expand Down
12 changes: 6 additions & 6 deletions configuration/backend_switching_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (c *client) GetBackendSwitchingRules(frontend string, transactionID string)

bckRules, err := ParseBackendSwitchingRules(frontend, p)
if err != nil {
return v, nil, c.HandleError("", "frontend", frontend, "", false, err)
return v, nil, c.HandleError("", FrontendParentName, frontend, "", false, err)
}

return v, bckRules, nil
Expand All @@ -64,7 +64,7 @@ func (c *client) GetBackendSwitchingRule(id int64, frontend string, transactionI

data, err := p.GetOne(parser.Frontends, frontend, "use_backend", int(id))
if err != nil {
return v, nil, c.HandleError(strconv.FormatInt(id, 10), "frontend", frontend, "", false, err)
return v, nil, c.HandleError(strconv.FormatInt(id, 10), FrontendParentName, frontend, "", false, err)
}

bckRule := ParseBackendSwitchingRule(data.(types.UseBackend))
Expand All @@ -82,7 +82,7 @@ func (c *client) DeleteBackendSwitchingRule(id int64, frontend string, transacti
}

if err := p.Delete(parser.Frontends, frontend, "use_backend", int(id)); err != nil {
return c.HandleError(strconv.FormatInt(id, 10), "frontend", frontend, t, transactionID == "", err)
return c.HandleError(strconv.FormatInt(id, 10), FrontendParentName, frontend, t, transactionID == "", err)
}

return c.SaveData(p, t, transactionID == "")
Expand All @@ -104,7 +104,7 @@ func (c *client) CreateBackendSwitchingRule(frontend string, data *models.Backen
}

if err := p.Insert(parser.Frontends, frontend, "use_backend", SerializeBackendSwitchingRule(*data), int(*data.Index)); err != nil {
return c.HandleError(strconv.FormatInt(*data.Index, 10), "frontend", frontend, t, transactionID == "", err)
return c.HandleError(strconv.FormatInt(*data.Index, 10), FrontendParentName, frontend, t, transactionID == "", err)
}

return c.SaveData(p, t, transactionID == "")
Expand All @@ -125,11 +125,11 @@ func (c *client) EditBackendSwitchingRule(id int64, frontend string, data *model
}

if _, err := p.GetOne(parser.Frontends, frontend, "use_backend", int(id)); err != nil {
return c.HandleError(strconv.FormatInt(id, 10), "frontend", frontend, t, transactionID == "", err)
return c.HandleError(strconv.FormatInt(id, 10), FrontendParentName, frontend, t, transactionID == "", err)
}

if err := p.Set(parser.Frontends, frontend, "use_backend", SerializeBackendSwitchingRule(*data), int(id)); err != nil {
return c.HandleError(strconv.FormatInt(id, 10), "frontend", frontend, t, transactionID == "", err)
return c.HandleError(strconv.FormatInt(id, 10), FrontendParentName, frontend, t, transactionID == "", err)
}

return c.SaveData(p, t, transactionID == "")
Expand Down
Loading

0 comments on commit fba3af8

Please sign in to comment.