@@ -127,23 +127,27 @@ func executeAgainstRunningDapr(t *testing.T, f func(), daprArgs ...string) {
127127// ensureDaprInstallation ensures that Dapr is installed.
128128// If Dapr is not installed, a new installation is attempted.
129129func ensureDaprInstallation (t * testing.T ) {
130- daprRuntimeVersion , _ := common .GetVersionsFromEnv (t , false )
131130 homeDir , err := os .UserHomeDir ()
132131 require .NoError (t , err , "failed to get user home directory" )
133132
134133 daprPath := filepath .Join (homeDir , ".dapr" )
135- _ , err = os .Stat (daprPath )
136- if os .IsNotExist (err ) {
137- args := []string {
138- "--runtime-version" , daprRuntimeVersion ,
134+ if _ , err = os .Stat (daprPath ); err != nil {
135+ if os .IsNotExist (err ) {
136+ installDapr (t )
137+ } else {
138+ // Some other error occurred.
139+ require .NoError (t , err , "failed to stat dapr installation" )
140+ }
141+ }
142+ daprBinPath := filepath .Join (daprPath , "bin" )
143+ if _ , err = os .Stat (daprBinPath ); err != nil {
144+ if os .IsNotExist (err ) {
145+ installDapr (t )
146+ } else {
147+ // Some other error occurred.
148+ require .NoError (t , err , "failed to stat dapr installation" )
139149 }
140- _ , err = cmdInit (args ... )
141- require .NoError (t , err , "failed to install dapr" )
142- } else if err != nil {
143- // Some other error occurred.
144- require .NoError (t , err , "failed to stat dapr installation" )
145150 }
146-
147151 // Slim mode does not have any resources by default.
148152 // Install the resources required by the tests.
149153 if isSlimMode () {
@@ -159,6 +163,15 @@ func containerRuntime() string {
159163 return ""
160164}
161165
166+ func installDapr (t * testing.T ) {
167+ daprRuntimeVersion , _ := common .GetVersionsFromEnv (t , false )
168+ args := []string {
169+ "--runtime-version" , daprRuntimeVersion ,
170+ }
171+ _ , err := cmdInit (args ... )
172+ require .NoError (t , err , "failed to install dapr" )
173+ }
174+
162175func uninstallDapr (uninstallArgs ... string ) (string , error ) {
163176 daprContainerRuntime := containerRuntime ()
164177
0 commit comments