Skip to content

Commit

Permalink
test: use generated red hat versions fixture if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Oct 29, 2024
1 parent af85088 commit 651e82d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions internal/semantic/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package semantic_test

import (
"bufio"
"errors"
"io/fs"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -239,6 +241,23 @@ func TestVersion_Compare_Ecosystems(t *testing.T) {
file: "redhat-versions.txt",
},
}

// we don't check the generated fixture for Red Hat in due to its size
// so we only add it if it exists, so that people can have it locally
// without needing to do a dance with git everytime they commit
_, err := os.Stat("fixtures/redhat-versions-generated.txt")
if err == nil {
tests = append(tests, struct {
name string
file string
}{
name: "Red Hat",
file: "redhat-versions-generated.txt",
})
} else if !errors.Is(err, fs.ErrNotExist) {
t.Fatalf("fixtures/redhat-versions-generated.txt exists but could not be read: %v", err)
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
Expand Down

0 comments on commit 651e82d

Please sign in to comment.