summaryrefslogtreecommitdiffstats
path: root/client/go/cmd/clone_test.go
blob: a98fed694fef6ca03ef51b6830c7202983fac916 (plain) (blame)
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
// 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 (
	"os"
	"path/filepath"
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/vespa-engine/vespa/util"
)

func TestClone(t *testing.T) {
	assertCreated("album-recommendation-selfhosted", "mytestapp", t)
}

func assertCreated(sampleAppName string, app string, t *testing.T) {
	existingSampleAppsZip = "testdata/sample-apps-master.zip"
	standardOut := executeCommand(t, &mockHttpClient{}, []string{"clone", sampleAppName, app}, []string{})
	defer os.RemoveAll(app)
	assert.Equal(t, "Created "+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())
}