@@ -85,23 +85,36 @@ func TestSetAccountId(t *testing.T) {
8585 assert .EqualError (t , err , "the command is being run in a non-interactive environment, please specify an account ID using --account-id" )
8686}
8787
88- func TestLoginPreservesClusterID (t * testing.T ) {
89- t .Setenv ("DATABRICKS_CONFIG_FILE" , "./testdata/.databrickscfg" )
90- clusterID , err := getClusterID (context .Background (), "cluster-profile" , "./testdata/.databrickscfg" )
91- require .NoError (t , err )
92- assert .Equal (t , "cluster-from-config" , clusterID )
93- }
88+ func TestLoginGetClusterID (t * testing.T ) {
89+ testCases := []struct {
90+ name string
91+ profile string
92+ expected string
93+ }{
94+ {
95+ name : "existing cluster profile" ,
96+ profile : "cluster-profile" ,
97+ expected : "cluster-from-config" ,
98+ },
99+ {
100+ name : "empty profile" ,
101+ profile : "no-profile" ,
102+ expected : "" ,
103+ },
104+ {
105+ name : "account profile" ,
106+ profile : "account-profile" ,
107+ expected : "" ,
108+ },
109+ }
94110
95- func TestLoginPreservesClusterIDWithEmptyHostAndAccountID (t * testing.T ) {
96111 t .Setenv ("DATABRICKS_CONFIG_FILE" , "./testdata/.databrickscfg" )
97- clusterID , err := getClusterID (context .Background (), "no-profile" , "./testdata/.databrickscfg" )
98- require .NoError (t , err )
99- assert .Equal (t , "" , clusterID )
100- }
101112
102- func TestLoginNoClusterIDWithAccountProfile (t * testing.T ) {
103- t .Setenv ("DATABRICKS_CONFIG_FILE" , "./testdata/.databrickscfg" )
104- clusterID , err := getClusterID (context .Background (), "account-profile" , "./testdata/.databrickscfg" )
105- require .NoError (t , err )
106- assert .Equal (t , "" , clusterID )
113+ for _ , tc := range testCases {
114+ t .Run (tc .name , func (t * testing.T ) {
115+ clusterID , err := getClusterID (context .Background (), tc .profile , "./testdata/.databrickscfg" )
116+ require .NoError (t , err )
117+ assert .Equal (t , tc .expected , clusterID )
118+ })
119+ }
107120}
0 commit comments