feat(delivery): refine base service integrations
This commit is contained in:
@@ -143,6 +143,35 @@ func TestRollbackExtraVarsTargetsOnlyTheAllocatedInstance(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDirectoryPathsFromAWXStdout(t *testing.T) {
|
||||
stdout := `
|
||||
TASK [Show directory completions] **********************************************
|
||||
ok: [db-01] => {
|
||||
"stdout": "XINFRA_PATH_COMPLETIONS_JSON=[{\"path\":\"/a/bc\",\"available_gi\":12},{\"path\":\"/a/bb\",\"available_gi\":8}]"
|
||||
}
|
||||
`
|
||||
items := directoryPathsFromAWXStdout(stdout)
|
||||
if len(items) != 2 {
|
||||
t.Fatalf("expected two completion items, got %#v", items)
|
||||
}
|
||||
if items[0].Path != "/a/bb" || items[1].Path != "/a/bc" {
|
||||
t.Fatalf("items should be parsed and sorted by path: %#v", items)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateDirectoryLookupPrefix(t *testing.T) {
|
||||
for _, path := range []string{"/", "/a", "/a/b", "/lib/data"} {
|
||||
if err := validateDirectoryLookupPrefix(path); err != nil {
|
||||
t.Fatalf("valid path prefix %q rejected: %v", path, err)
|
||||
}
|
||||
}
|
||||
for _, path := range []string{"a", "relative/path"} {
|
||||
if err := validateDirectoryLookupPrefix(path); err == nil {
|
||||
t.Fatalf("invalid path prefix %q was accepted", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterFailedIsProtectedFromRollback(t *testing.T) {
|
||||
if !rollbackProtectedStatus(model.TaskRegisterFailed) {
|
||||
t.Fatal("register_failed must preserve the healthy instance and resource usage")
|
||||
|
||||
Reference in New Issue
Block a user