Skip to content

Commit 3c75bf6

Browse files
committed
expand scope of validation test and check validation
1 parent 43c4ec2 commit 3c75bf6

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

.github/workflows/validation-lambdalabs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
pull_request:
1010
paths:
1111
- 'internal/lambdalabs/**'
12+
- 'pkg/v1/**'
1213
branches: [ main ]
1314

1415
jobs:
@@ -43,6 +44,7 @@ jobs:
4344
LAMBDALABS_API_KEY: ${{ secrets.LAMBDALABS_API_KEY }}
4445
TEST_PRIVATE_KEY_BASE64: ${{ secrets.TEST_PRIVATE_KEY_BASE64 }}
4546
TEST_PUBLIC_KEY_BASE64: ${{ secrets.TEST_PUBLIC_KEY_BASE64 }}
47+
VALIDATION_TEST: true
4648
run: |
4749
cd internal/lambdalabs
4850
go test -v -short=false -timeout=30m ./...

internal/lambdalabs/v1/validation_test.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import (
99
)
1010

1111
func 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

2523
func 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

Comments
 (0)