@@ -9,10 +9,8 @@ import (
99)
1010
1111func TestValidationFunctions (t * testing.T ) {
12- apiKey := os .Getenv ("LAMBDALABS_API_KEY" )
13- if apiKey == "" {
14- t .Skip ("LAMBDALABS_API_KEY not set, skipping LambdaLabs validation tests" )
15- }
12+ checkSkip (t )
13+ apiKey := getAPIKey ()
1614
1715 config := validation.ProviderConfig {
1816 Credential : NewLambdaLabsCredential ("validation-test" , apiKey ),
@@ -23,14 +21,26 @@ func TestValidationFunctions(t *testing.T) {
2321}
2422
2523func TestInstanceLifecycleValidation (t * testing.T ) {
26- apiKey := os .Getenv ("LAMBDALABS_API_KEY" )
27- if apiKey == "" {
28- t .Skip ("LAMBDALABS_API_KEY not set, skipping LambdaLabs validation tests" )
29- }
24+ checkSkip (t )
25+ apiKey := getAPIKey ()
3026
3127 config := validation.ProviderConfig {
3228 Credential : NewLambdaLabsCredential ("validation-test" , apiKey ),
3329 }
3430
3531 validation .RunInstanceLifecycleValidation (t , config )
3632}
33+
34+ func checkSkip (t * testing.T ) {
35+ apiKey := getAPIKey ()
36+ isValidationTest := os .Getenv ("VALIDATION_TEST" )
37+ if apiKey == "" && isValidationTest != "" {
38+ t .Fatal ("LAMBDALABS_API_KEY not set, but VALIDATION_TEST is set" )
39+ } else if apiKey == "" && isValidationTest == "" {
40+ t .Skip ("LAMBDALABS_API_KEY not set, skipping LambdaLabs validation tests" )
41+ }
42+ }
43+
44+ func getAPIKey () string {
45+ return os .Getenv ("LAMBDALABS_API_KEY" )
46+ }
0 commit comments