Fix: image alias put query
All checks were successful
All checks were successful
This commit is contained in:
@@ -11,15 +11,45 @@ type putImageAliasPayload struct {
|
||||
}
|
||||
|
||||
func Test_03_PutImageAliases(t *testing.T) {
|
||||
payload := putImageAliasPayload{
|
||||
Aliases: []string{"huh"},
|
||||
}
|
||||
resp, err := client.R().
|
||||
SetBody(payload).
|
||||
Put(fmt.Sprintf("http://localhost:8080/api/image/%d/aliases",
|
||||
image.Id))
|
||||
if err != nil || resp.StatusCode() != http.StatusOK {
|
||||
t.Logf("%+v", resp)
|
||||
t.Fatal("failed to put image alias")
|
||||
}
|
||||
t.Run("Put one alias", func(t *testing.T) {
|
||||
payload := putImageAliasPayload{
|
||||
Aliases: []string{"huh"},
|
||||
}
|
||||
resp, err := client.R().
|
||||
SetBody(payload).
|
||||
Put(fmt.Sprintf("http://localhost:8080/api/image/%d/aliases",
|
||||
image.Id))
|
||||
if err != nil || resp.StatusCode() != http.StatusOK {
|
||||
t.Logf("%+v", resp)
|
||||
t.Fatal("failed to put image alias")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Put many alias", func(t *testing.T) {
|
||||
payload := putImageAliasPayload{
|
||||
Aliases: []string{"huh", "testalias1", "testalias2"},
|
||||
}
|
||||
resp, err := client.R().
|
||||
SetBody(payload).
|
||||
Put(fmt.Sprintf("http://localhost:8080/api/image/%d/aliases",
|
||||
image.Id))
|
||||
if err != nil || resp.StatusCode() != http.StatusOK {
|
||||
t.Logf("%+v", resp)
|
||||
t.Fatal("failed to put image alias")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Remove alias", func(t *testing.T) {
|
||||
payload := putImageAliasPayload{
|
||||
Aliases: []string{"huh", "testalias1"},
|
||||
}
|
||||
resp, err := client.R().
|
||||
SetBody(payload).
|
||||
Put(fmt.Sprintf("http://localhost:8080/api/image/%d/aliases",
|
||||
image.Id))
|
||||
if err != nil || resp.StatusCode() != http.StatusOK {
|
||||
t.Logf("%+v", resp)
|
||||
t.Fatal("failed to put image alias")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,9 +7,11 @@ import (
|
||||
)
|
||||
|
||||
func Test_07_DeleteAlias(t *testing.T) {
|
||||
deleteId := aliases[0].Id
|
||||
|
||||
resp, err := client.R().
|
||||
Delete(fmt.Sprintf("http://localhost:8080/api/alias/%d",
|
||||
aliases[0].Id))
|
||||
deleteId))
|
||||
if err != nil || resp.StatusCode() != http.StatusOK {
|
||||
t.Logf("%+v", resp)
|
||||
t.Fatal("failed to delete alias")
|
||||
@@ -23,7 +25,10 @@ func Test_07_DeleteAlias(t *testing.T) {
|
||||
t.Fatal("failed to get aliases")
|
||||
}
|
||||
|
||||
if len(aliases) > 0 {
|
||||
t.Fatal("alias not deleted")
|
||||
for _, alias := range aliases {
|
||||
if alias.Id == deleteId {
|
||||
t.Logf("%+v", resp)
|
||||
t.Fatal("alias not deleted")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user