Skip to content

Commit

Permalink
Cleanup after unit deployment test. Add functions to excercise host A…
Browse files Browse the repository at this point in the history
…PI functions that print.
  • Loading branch information
Szubie committed Jun 16, 2022
1 parent af1960a commit 9f6af59
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions platform/host_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ func Test_InitUnit(t *testing.T) {
bravefile.PlatformService.Resources.CPU = "1"
bravefile.PlatformService.Resources.RAM = "1GB"

bravefile.PlatformService.Postdeploy.Run = []shared.RunCommand{
{
Command: "echo",
Args: []string{"Hello World"},
},
}

err := host.BuildImage(&bravefile)
if err != nil {
t.Error("host.BuildImage: ", err)
Expand All @@ -100,8 +107,58 @@ func Test_InitUnit(t *testing.T) {
t.Error("host.InitUnit: ", err)
}

err = host.Postdeploy(&bravefile)
if err != nil {
t.Error("host.Postdeploy: ", err)
}

err = host.DeleteLocalImage("alpine-test-1.0")
if err != nil {
t.Error("host.DeleteImageByName: ", err)
}

err = host.StopUnit("alpine-test", backend)
if err != nil {
t.Error("host.StopUnit: ", err)
}

err = host.StartUnit("alpine-test", backend)
if err != nil {
t.Error("host.StartUnit: ", err)
}

err = host.DeleteUnit("alpine-test")
if err != nil {
t.Error("host.DeleteUnit: ", err)
}
}

func Test_ListLocalImages(t *testing.T) {
host := *NewBraveHost()
backend := NewLxd(host.Settings)

err := host.HostInfo(backend, false)
if err != nil {
t.Error("host.HostInfo: ", err)
}

err = host.ListLocalImages()
if err != nil {
t.Error("host.ListLocalImages: ", err)
}
}

func Test_ListUnits(t *testing.T) {
host := *NewBraveHost()
backend := NewLxd(host.Settings)

err := host.HostInfo(backend, false)
if err != nil {
t.Error("host.HostInfo: ", err)
}

err = host.ListUnits(backend)
if err != nil {
t.Error("host.ListLocalImages: ", err)
}
}

0 comments on commit 9f6af59

Please sign in to comment.