diff options
Diffstat (limited to 'client/go/cmd/init_test.go')
-rw-r--r-- | client/go/cmd/init_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/client/go/cmd/init_test.go b/client/go/cmd/init_test.go new file mode 100644 index 00000000000..3cb526ad0f1 --- /dev/null +++ b/client/go/cmd/init_test.go @@ -0,0 +1,32 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// init command tests +// Author: bratseth + +package cmd + +import ( + "github.com/vespa-engine/vespa/util" + "github.com/stretchr/testify/assert" + "os" + "testing" + "path/filepath" +) + +func TestInit(t *testing.T) { + assertCreated("mytestapp", "album-recommendation-selfhosted", t) +} + +func assertCreated(app string, sampleAppName string, t *testing.T) { + existingSampleAppsZip = "testdata/sample-apps-master.zip" + standardOut := executeCommand(t, &mockHttpClient{}, []string{"init", app, sampleAppName}, []string{}) + defer os.RemoveAll(app) + assert.Equal(t, "\x1b[32mCreated " + app + "\n", standardOut) + assert.True(t, util.PathExists(filepath.Join(app, "README.md"))) + assert.True(t, util.PathExists(filepath.Join(app, "src", "main", "application"))) + assert.True(t, util.IsDirectory(filepath.Join(app, "src", "main", "application"))) + + servicesStat, _ := os.Stat(filepath.Join(app, "src", "main", "application", "services.xml")) + var servicesSize int64 + servicesSize = 2474 + assert.Equal(t, servicesSize, servicesStat.Size()) +} |