-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathbuild_test.go
81 lines (59 loc) · 1.53 KB
/
build_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package build
import (
"jmm/pkg/lib/constants"
"path"
"testing"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
)
func TestNewCmdBuild(t *testing.T) {
cmd := NewCmdBuild()
assert.NotNil(t, cmd)
assert.Equal(t, "build", cmd.Use)
assert.Equal(t, shortDesc, cmd.Short)
assert.Equal(t, longDesc, cmd.Long)
}
func TestBuildOptions_Complete(t *testing.T) {
options := &BuildOptions{}
cmd := &cobra.Command{}
args := []string{"arg1"}
err := options.Complete(cmd, args)
assert.NoError(t, err)
assert.Equal(t, args[0], options.ContextDir)
assert.Equal(t, path.Join(options.ContextDir, constants.DefaultModelFileName), options.ModelFile)
}
func TestBuildOptions_Validate(t *testing.T) {
options := &BuildOptions{
ModelFile: "Jozufile",
ContextDir: "/path/to/context",
}
err := options.Validate()
assert.NoError(t, err)
}
func TestBuildOptions_RunBuild(t *testing.T) {
t.Skip("Skipping test for now")
options := &BuildOptions{
ModelFile: "Jozufile",
ContextDir: "/path/to/context",
}
err := options.RunBuild()
assert.NoError(t, err)
}
func TestBuildFlags_ToOptions(t *testing.T) {
flags := &BuildFlags{
ModelFile: "Jozufile",
}
options, err := flags.ToOptions()
assert.NoError(t, err)
assert.Equal(t, flags.ModelFile, options.ModelFile)
}
func TestBuildFlags_AddFlags(t *testing.T) {
flags := &BuildFlags{}
cmd := &cobra.Command{}
flags.AddFlags(cmd)
assert.NotNil(t, cmd.Flags().Lookup("file"))
}
func TestNewBuildFlags(t *testing.T) {
flags := NewBuildFlags()
assert.NotNil(t, flags)
}