Fix: image alias put query
All checks were successful
All checks were successful
This commit is contained in:
@@ -184,6 +184,14 @@ func (self *BunDatabase) UpdateAliases(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = tx.NewSelect().
|
||||||
|
Model(&aliases).
|
||||||
|
Where("name IN (?)", bun.In(aliasNames)).
|
||||||
|
Scan(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
var rels []models.AliasImage
|
var rels []models.AliasImage
|
||||||
for _, alias := range aliases {
|
for _, alias := range aliases {
|
||||||
rels = append(rels, models.AliasImage{
|
rels = append(rels, models.AliasImage{
|
||||||
|
|||||||
@@ -11,15 +11,45 @@ type putImageAliasPayload struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_03_PutImageAliases(t *testing.T) {
|
func Test_03_PutImageAliases(t *testing.T) {
|
||||||
payload := putImageAliasPayload{
|
t.Run("Put one alias", func(t *testing.T) {
|
||||||
Aliases: []string{"huh"},
|
payload := putImageAliasPayload{
|
||||||
}
|
Aliases: []string{"huh"},
|
||||||
resp, err := client.R().
|
}
|
||||||
SetBody(payload).
|
resp, err := client.R().
|
||||||
Put(fmt.Sprintf("http://localhost:8080/api/image/%d/aliases",
|
SetBody(payload).
|
||||||
image.Id))
|
Put(fmt.Sprintf("http://localhost:8080/api/image/%d/aliases",
|
||||||
if err != nil || resp.StatusCode() != http.StatusOK {
|
image.Id))
|
||||||
t.Logf("%+v", resp)
|
if err != nil || resp.StatusCode() != http.StatusOK {
|
||||||
t.Fatal("failed to put image alias")
|
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) {
|
func Test_07_DeleteAlias(t *testing.T) {
|
||||||
|
deleteId := aliases[0].Id
|
||||||
|
|
||||||
resp, err := client.R().
|
resp, err := client.R().
|
||||||
Delete(fmt.Sprintf("http://localhost:8080/api/alias/%d",
|
Delete(fmt.Sprintf("http://localhost:8080/api/alias/%d",
|
||||||
aliases[0].Id))
|
deleteId))
|
||||||
if err != nil || resp.StatusCode() != http.StatusOK {
|
if err != nil || resp.StatusCode() != http.StatusOK {
|
||||||
t.Logf("%+v", resp)
|
t.Logf("%+v", resp)
|
||||||
t.Fatal("failed to delete alias")
|
t.Fatal("failed to delete alias")
|
||||||
@@ -23,7 +25,10 @@ func Test_07_DeleteAlias(t *testing.T) {
|
|||||||
t.Fatal("failed to get aliases")
|
t.Fatal("failed to get aliases")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(aliases) > 0 {
|
for _, alias := range aliases {
|
||||||
t.Fatal("alias not deleted")
|
if alias.Id == deleteId {
|
||||||
|
t.Logf("%+v", resp)
|
||||||
|
t.Fatal("alias not deleted")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user