Skip to content

Commit

Permalink
Complete tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Sep 19, 2024
1 parent f984b37 commit d07e76a
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 222 deletions.
17 changes: 9 additions & 8 deletions cmd/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,15 @@ func mustMarshalToMultiYAML[R any](t *testing.T, data []R) []byte {
return []byte(strings.Join(parts, "\n---\n"))
}

func mustJsonDeepCopy[O any](t *testing.T, object O) O {
raw, err := json.Marshal(&object)
require.NoError(t, err)
var copy O
err = json.Unmarshal(raw, &copy)
require.NoError(t, err)
return copy
}
// might come in handy later:
// func mustJsonDeepCopy[O any](t *testing.T, object O) O {
// raw, err := json.Marshal(&object)
// require.NoError(t, err)
// var copy O
// err = json.Unmarshal(raw, &copy)
// require.NoError(t, err)
// return copy
// }

func outputFormats[R any](c *test[R]) []outputFormat[R] {
var formats []outputFormat[R]
Expand Down
5 changes: 5 additions & 0 deletions cmd/project-reservations.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"

"github.com/fi-ts/cloud-go/api/client/project"
Expand Down Expand Up @@ -135,6 +136,10 @@ func (m machineReservationsCmd) Create(rq *models.V1MachineReservationCreateRequ
WithBody(rq).
WithForce(pointer.Pointer(viper.GetBool("force"))), nil)
if err != nil {
var r *project.CreateMachineReservationConflict
if errors.As(err, &r) {
return nil, genericcli.AlreadyExistsError()
}
return nil, err
}

Expand Down
Loading

0 comments on commit d07e76a

Please sign in to comment.