Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ ops.exe
vendor/
.idea

cmd/nodejs*

config*.json
load*
coverage.out
5 changes: 2 additions & 3 deletions cmd/cmd_build_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package cmd_test
package cmd

import (
"os"
"testing"

"github.com/nanovms/ops/cmd"
"github.com/nanovms/ops/testutils"
"github.com/stretchr/testify/assert"
)
Expand All @@ -13,7 +12,7 @@ func TestCmdBuild(t *testing.T) {
programPath := testutils.BuildBasicProgram()
defer os.Remove(programPath)

buildCmd := cmd.BuildCommand()
buildCmd := BuildCommand()

buildCmd.SetArgs([]string{programPath})

Expand Down
9 changes: 4 additions & 5 deletions cmd/cmd_image_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package cmd_test
package cmd

import (
"os"
"testing"

"github.com/nanovms/ops/cmd"
"github.com/nanovms/ops/testutils"
"github.com/stretchr/testify/assert"
)
Expand All @@ -13,7 +12,7 @@ func TestCreateImage(t *testing.T) {
basicProgram := testutils.BuildBasicProgram()
defer os.Remove(basicProgram)

createImageCmd := cmd.ImageCommands()
createImageCmd := ImageCommands()

createImageCmd.SetArgs([]string{"create", basicProgram})

Expand All @@ -27,7 +26,7 @@ func TestCreateImage(t *testing.T) {
}

func TestListImages(t *testing.T) {
listImagesCmd := cmd.ImageCommands()
listImagesCmd := ImageCommands()

listImagesCmd.SetArgs([]string{"list"})

Expand All @@ -39,7 +38,7 @@ func TestListImages(t *testing.T) {
func TestDeleteImage(t *testing.T) {
imagePath := buildImage("test-img")

deleteImageCmd := cmd.ImageCommands()
deleteImageCmd := ImageCommands()

deleteImageCmd.SetArgs([]string{"delete", imagePath, "--assume-yes"})

Expand Down
9 changes: 4 additions & 5 deletions cmd/cmd_instance_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package cmd_test
package cmd

import (
"testing"

"github.com/nanovms/ops/cmd"
"github.com/nanovms/ops/testutils"
"github.com/stretchr/testify/assert"
)
Expand All @@ -15,7 +14,7 @@ func TestCreateInstance(t *testing.T) {

instanceName := imageName + testutils.String(5)

createInstanceCmd := cmd.InstanceCommands()
createInstanceCmd := InstanceCommands()

createInstanceCmd.SetArgs([]string{"create", imageName, "--instance-name", instanceName})

Expand All @@ -27,7 +26,7 @@ func TestCreateInstance(t *testing.T) {
}

func TestListInstances(t *testing.T) {
listInstancesCmd := cmd.InstanceCommands()
listInstancesCmd := InstanceCommands()

listInstancesCmd.SetArgs([]string{"list"})

Expand All @@ -41,7 +40,7 @@ func TestDeleteInstance(t *testing.T) {
defer removeImage(imageName)
instanceName := buildInstance(imageName)

deleteInstanceCmd := cmd.InstanceCommands()
deleteInstanceCmd := InstanceCommands()

deleteInstanceCmd.SetArgs([]string{"delete", instanceName})

Expand Down
15 changes: 7 additions & 8 deletions cmd/cmd_pkg_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package cmd_test
package cmd

import (
"os"
"testing"

"github.com/nanovms/ops/cmd"
"github.com/stretchr/testify/assert"
)

func TestListPkgCommand(t *testing.T) {
listPkgCmd := cmd.PackageCommands()
listPkgCmd := PackageCommands()

listPkgCmd.SetArgs([]string{"list"})

Expand All @@ -19,7 +18,7 @@ func TestListPkgCommand(t *testing.T) {
}

func TestGetPkgCommand(t *testing.T) {
getPkgCmd := cmd.PackageCommands()
getPkgCmd := PackageCommands()

getPkgCmd.SetArgs([]string{"get", "eyberg/bind:9.13.4", "--arch", "amd64"})

Expand All @@ -29,7 +28,7 @@ func TestGetPkgCommand(t *testing.T) {
}

func TestPkgContentsCommand(t *testing.T) {
getPkgCmd := cmd.PackageCommands()
getPkgCmd := PackageCommands()

getPkgCmd.SetArgs([]string{"contents", "eyberg/bind:9.13.4"})

Expand All @@ -39,7 +38,7 @@ func TestPkgContentsCommand(t *testing.T) {
}

func TestPkgDescribeCommand(t *testing.T) {
getPkgCmd := cmd.PackageCommands()
getPkgCmd := PackageCommands()

getPkgCmd.SetArgs([]string{"describe", "eyberg/bind:9.13.4", "--arch", "amd64"})

Expand All @@ -50,7 +49,7 @@ func TestPkgDescribeCommand(t *testing.T) {

func TestLoad(t *testing.T) {

getPkgCmd := cmd.PackageCommands()
getPkgCmd := PackageCommands()

program := buildNodejsProgram()
defer os.Remove(program)
Expand All @@ -65,7 +64,7 @@ func TestLoad(t *testing.T) {
}

func TestPkgSearch(t *testing.T) {
searchPkgCmd := cmd.PackageCommands()
searchPkgCmd := PackageCommands()

searchPkgCmd.SetArgs([]string{"search", "mysql"})
err := searchPkgCmd.Execute()
Expand Down
5 changes: 2 additions & 3 deletions cmd/cmd_profile_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package cmd_test
package cmd

import (
"testing"

"github.com/nanovms/ops/cmd"
"github.com/stretchr/testify/assert"
)

func TestProfileCommand(t *testing.T) {
profileCommand := cmd.ProfileCommand()
profileCommand := ProfileCommand()

err := profileCommand.Execute()

Expand Down
5 changes: 2 additions & 3 deletions cmd/cmd_run_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package cmd_test
package cmd

import (
"os"
"testing"

"github.com/nanovms/ops/cmd"
"github.com/nanovms/ops/testutils"
"github.com/stretchr/testify/assert"
)
Expand All @@ -13,7 +12,7 @@ func TestRunCommand(t *testing.T) {
programPath := testutils.BuildBasicProgram()
defer os.Remove(programPath)

runCmd := cmd.RunCommand()
runCmd := RunCommand()

runCmd.SetArgs([]string{programPath})

Expand Down
5 changes: 2 additions & 3 deletions cmd/cmd_version_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package cmd_test
package cmd

import (
"testing"

"github.com/nanovms/ops/cmd"
"github.com/stretchr/testify/assert"
)

func TestVersionCommand(t *testing.T) {
versionCmd := cmd.VersionCommand()
versionCmd := VersionCommand()

err := versionCmd.Execute()

Expand Down
17 changes: 7 additions & 10 deletions cmd/cmd_volume_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd_test
package cmd

import (
"os"
Expand All @@ -8,12 +8,11 @@ import (
"github.com/nanovms/ops/testutils"
"github.com/nanovms/ops/types"

"github.com/nanovms/ops/cmd"
"github.com/stretchr/testify/assert"
)

func TestCreateVolumeCommand(t *testing.T) {
createVolumeCmd := cmd.VolumeCommands()
createVolumeCmd := VolumeCommands()

createVolumeCmd.SetArgs([]string{"create", "test"})

Expand All @@ -23,7 +22,7 @@ func TestCreateVolumeCommand(t *testing.T) {
}

func TestListVolumesCommand(t *testing.T) {
listVolumesCmd := cmd.VolumeCommands()
listVolumesCmd := VolumeCommands()

listVolumesCmd.SetArgs([]string{"list"})

Expand All @@ -33,7 +32,7 @@ func TestListVolumesCommand(t *testing.T) {
}

func TestDeleteVolumeCommand(t *testing.T) {
deleteVolumeCmd := cmd.VolumeCommands()
deleteVolumeCmd := VolumeCommands()

deleteVolumeCmd.SetArgs([]string{"delete", "test"})

Expand Down Expand Up @@ -62,7 +61,7 @@ func TestAttachVolumeCommand(t *testing.T) {
volumeName := buildVolume("vol-test")
defer removeVolume(volumeName)

attachVolumeCmd := cmd.VolumeCommands()
attachVolumeCmd := VolumeCommands()

attachVolumeCmd.SetArgs([]string{"attach", instanceName, volumeName, "does not matter"})

Expand Down Expand Up @@ -94,7 +93,7 @@ func TestDetachVolumeCommand(t *testing.T) {
volumeName := buildVolume("vol-test")
defer removeVolume(volumeName)

attachVolumeCmd := cmd.VolumeCommands()
attachVolumeCmd := VolumeCommands()

attachVolumeCmd.SetArgs([]string{"attach", instanceName, volumeName, "does not matter"})

Expand All @@ -105,9 +104,7 @@ func TestDetachVolumeCommand(t *testing.T) {

assert.Nil(t, err)

//

detachVolumeCmd := cmd.VolumeCommands()
detachVolumeCmd := VolumeCommands()

detachVolumeCmd.SetArgs([]string{"detach", instanceName, volumeName})

Expand Down
13 changes: 6 additions & 7 deletions cmd/flags_build_image_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package cmd_test
package cmd

import (
"testing"

"github.com/nanovms/ops/types"

"github.com/nanovms/ops/cmd"
"github.com/nanovms/ops/lepton"
"github.com/spf13/pflag"
"github.com/stretchr/testify/assert"
Expand All @@ -26,7 +25,7 @@ func TestCreateBuildImageFlags(t *testing.T) {
flagSet.Set("gateway", "192.168.1.254")
flagSet.Set("netmask", "255.255.0.0")

buildImageFlags := cmd.NewBuildImageCommandFlags(flagSet)
buildImageFlags := NewBuildImageCommandFlags(flagSet)

assert.Equal(t, buildImageFlags.CmdEnvs, []string{"test=1234"})
assert.Equal(t, buildImageFlags.TargetRoot, "unix")
Expand All @@ -48,15 +47,15 @@ func TestBuildImageFlagsMergeToConfig(t *testing.T) {

flagSet := pflag.NewFlagSet("test", 0)

cmd.PersistBuildImageCommandFlags(flagSet)
PersistBuildImageCommandFlags(flagSet)

flagSet.Set("args", "a b c d")
flagSet.Set("envs", "test=1234")
flagSet.Set("target-root", "unix")
flagSet.Set("imagename", "test-image")
flagSet.Set("mounts", volumeName+":/files")

buildImageFlags := cmd.NewBuildImageCommandFlags(flagSet)
buildImageFlags := NewBuildImageCommandFlags(flagSet)

opsPath := lepton.GetOpsHome() + "/" + lepton.LocalReleaseVersion
imagesPath := lepton.GetOpsHome() + "/images"
Expand Down Expand Up @@ -100,7 +99,7 @@ func TestBuildImageFlagsMergeToConfig(t *testing.T) {
t.Run("should clear ip/gateway/netmask if they are not valid ip addresses", func(t *testing.T) {
flagSet := newBuildImageFlagSet()

runLocalInstanceFlags := cmd.NewBuildImageCommandFlags(flagSet)
runLocalInstanceFlags := NewBuildImageCommandFlags(flagSet)
runLocalInstanceFlags.IPAddress = "tomato"
runLocalInstanceFlags.Gateway = "potato"
runLocalInstanceFlags.Netmask = "cheese"
Expand Down Expand Up @@ -133,6 +132,6 @@ func TestBuildImageFlagsMergeToConfig(t *testing.T) {
func newBuildImageFlagSet() (flagSet *pflag.FlagSet) {
flagSet = pflag.NewFlagSet("test", 0)

cmd.PersistBuildImageCommandFlags(flagSet)
PersistBuildImageCommandFlags(flagSet)
return
}
Loading