gitlab.com/sparetimecoders/build-tools@v0.1.0/cmd/kubecmd/kubecmd_test.go (about)

     1  package main
     2  
     3  import (
     4  	"github.com/stretchr/testify/assert"
     5  	"io/ioutil"
     6  	"os"
     7  	"path/filepath"
     8  	"testing"
     9  )
    10  
    11  func TestKubecmd_MissingArguments(t *testing.T) {
    12  	os.Args = []string{"kubecmd"}
    13  	main()
    14  }
    15  
    16  func TestKubecmd_NoOptions(t *testing.T) {
    17  	oldPwd, _ := os.Getwd()
    18  	name, _ := ioutil.TempDir(os.TempDir(), "build-tools")
    19  	defer os.RemoveAll(name)
    20  	yaml := `
    21  environments:
    22    - name: dummy
    23      context: missing
    24      namespace: none
    25  `
    26  	_ = ioutil.WriteFile(filepath.Join(name, ".buildtools.yaml"), []byte(yaml), 0777)
    27  
    28  	err := os.Chdir(name)
    29  	assert.NoError(t, err)
    30  	defer os.Chdir(oldPwd)
    31  
    32  	os.Args = []string{"deploy", "dummy"}
    33  	main()
    34  }