Skip to content

Commit

Permalink
tests: fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
  • Loading branch information
fgiudici committed Aug 9, 2024
1 parent a8fb0e2 commit ae1c7d9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
9 changes: 2 additions & 7 deletions cmd/register/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package main

import (
"encoding/json"
"fmt"
"os"
"path"
Expand Down Expand Up @@ -276,15 +275,13 @@ var _ = Describe("elemental-register --install", Label("registration", "cli", "i
stateHandler.EXPECT().Save(stateFixture).Return(nil)
})
It("should trigger install when --install argument", func() {
wantConfigJson, err := json.Marshal(networkConfigFixture)
Expect(err).ShouldNot(HaveOccurred())

cmd.SetArgs([]string{"--install"})
client.EXPECT().GetNetworkConfig(alternateConfigFixture.Elemental.Registration, []byte(alternateConfigFixture.Elemental.Registration.CACert), gomock.Any()).Return(wantConfigJson, nil)
installer.EXPECT().InstallElemental(alternateConfigFixture, stateFixture, networkConfigFixture).Return(nil)
client.EXPECT().
Register(baseConfigFixture.Elemental.Registration, []byte(baseConfigFixture.Elemental.Registration.CACert), &stateFixture).
Return(marshalToBytes(alternateConfigFixture), nil)
Return(append(marshalToBytes(alternateConfigFixture), marshalToBytes(networkConfigFixture)...), nil)
Expect(cmd.Execute()).ToNot(HaveOccurred())
})
})
Expand Down Expand Up @@ -354,15 +351,13 @@ var _ = Describe("elemental-register --reset", Label("registration", "cli", "res
stateHandler.EXPECT().Save(register.State{}).Return(nil)
})
It("should trigger reset when --reset argument", func() {
wantConfigJson, err := json.Marshal(networkConfigFixture)
Expect(err).ShouldNot(HaveOccurred())

cmd.SetArgs([]string{"--reset"})
client.EXPECT().GetNetworkConfig(alternateConfigFixture.Elemental.Registration, []byte(alternateConfigFixture.Elemental.Registration.CACert), gomock.Any()).Return(wantConfigJson, nil)
installer.EXPECT().ResetElemental(alternateConfigFixture, register.State{}, networkConfigFixture).Return(nil)
client.EXPECT().
Register(baseConfigFixture.Elemental.Registration, []byte(baseConfigFixture.Elemental.Registration.CACert), &register.State{}).
Return(marshalToBytes(alternateConfigFixture), nil)
Return(append(marshalToBytes(alternateConfigFixture), marshalToBytes(networkConfigFixture)...), nil)
Expect(cmd.Execute()).ToNot(HaveOccurred())
})
})
Expand Down
15 changes: 0 additions & 15 deletions pkg/register/mocks/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ae1c7d9

Please sign in to comment.