github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/projectfile/create_test.go (about) 1 package projectfile 2 3 import ( 4 "path/filepath" 5 "testing" 6 7 "github.com/ActiveState/cli/internal/constants" 8 "github.com/ActiveState/cli/internal/fileutils" 9 "github.com/stretchr/testify/assert" 10 "github.com/stretchr/testify/require" 11 ) 12 13 func Test_Create(t *testing.T) { 14 tempDir := fileutils.TempDirUnsafe() 15 type args struct { 16 org string 17 project string 18 directory string 19 language string 20 } 21 tests := []struct { 22 name string 23 args args 24 want error 25 wantContents string 26 }{ 27 { 28 "orgName/projName", 29 args{"orgName", "projName", tempDir, "python3"}, 30 nil, 31 "orgName/projName?branch=main", 32 }, 33 } 34 for _, tt := range tests { 35 t.Run(tt.name, func(t *testing.T) { 36 _, err := Create(&CreateParams{ 37 Owner: tt.args.org, 38 Project: tt.args.project, 39 Directory: tt.args.directory, 40 Language: tt.args.language, 41 }) 42 assert.NoError(t, err) 43 configFile := filepath.Join(tempDir, constants.ConfigFileName) 44 require.FileExists(t, configFile) 45 assert.Contains(t, string(fileutils.ReadFileUnsafe(configFile)), tt.wantContents) 46 }) 47 } 48 }