Skip to content

Commit

Permalink
skip non-exist config file
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-henglu committed Mar 6, 2025
1 parent 553b425 commit 9872b95
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions internal/services/azapi_resource_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ func ListTestcases(resourceTypeDir string, includingRootTestcase bool) []Example

if includingRootTestcase {
rootConfig := path.Join(resourceTypeDir, "main.tf")
if tc, err := LoadTestcase(rootConfig); err == nil {
testcases = append(testcases, *tc)
} else {
fmt.Printf("[WARN] Error loading config %s: %v\n", rootConfig, err)
if _, err := os.Stat(rootConfig); err == nil {
if tc, err := LoadTestcase(rootConfig); err == nil {
testcases = append(testcases, *tc)
} else {
fmt.Printf("[WARN] Error loading config %s: %v\n", rootConfig, err)
}
}
}

Expand All @@ -129,10 +131,12 @@ func ListTestcases(resourceTypeDir string, includingRootTestcase bool) []Example
}

subConfig := path.Join(resourceTypeDir, subDir.Name(), "main.tf")
if tc, err := LoadTestcase(subConfig); err == nil {
testcases = append(testcases, *tc)
} else {
fmt.Printf("[WARN] Error loading config %s: %v\n", subConfig, err)
if _, err := os.Stat(subConfig); err == nil {
if tc, err := LoadTestcase(subConfig); err == nil {
testcases = append(testcases, *tc)
} else {
fmt.Printf("[WARN] Error loading config %s: %v\n", subConfig, err)
}
}
}

Expand Down

0 comments on commit 9872b95

Please sign in to comment.