Skip to content

Commit

Permalink
APIF-1427 renames methods for uploading tests to the cloud (#761)
Browse files Browse the repository at this point in the history
In APIT we have a feature called "Load Test", here we are renaming
the method 'loadTest' to 'newTest' to prevent ambiguity.
  • Loading branch information
flyingsaucervargas authored May 2, 2023
1 parent 5975ae1 commit 026fdd1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions internal/apitest/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func findTests(rootDir string, testMatch []string) ([]string, error) {
return tests, nil
}

func loadTest(testDir string, suiteName string, testName string, tags []string, env map[string]string) (TestRequest, error) {
func newTestRequest(testDir string, suiteName string, testName string, tags []string, env map[string]string) (TestRequest, error) {
unitFile, err := findUnitFile(testDir)
if err != nil {
return TestRequest{}, err
Expand Down Expand Up @@ -226,11 +226,11 @@ func loadTest(testDir string, suiteName string, testName string, tags []string,
}, nil
}

func (r *Runner) loadTests(s Suite, tests []string) []TestRequest {
func (r *Runner) newTestRequests(s Suite, tests []string) []TestRequest {
var testRequests []TestRequest

for _, test := range tests {
req, err := loadTest(
req, err := newTestRequest(
path.Join(r.Project.RootDir, test),
s.Name,
test,
Expand All @@ -241,7 +241,7 @@ func (r *Runner) loadTests(s Suite, tests []string) []TestRequest {
log.Warn().
Str("testName", test).
Err(err).
Msg("Unable to load test.")
Msg("Unable to open test.")
}
testRequests = append(testRequests, req)
}
Expand All @@ -265,9 +265,9 @@ func (r *Runner) runLocalTests(s Suite, results chan []TestResult) int {
log.Error().Err(err).Str("rootDir", r.Project.RootDir).Msg("Unable to walk rootDir")
return 0
}
tests := r.loadTests(s, matchingTests)
tests := r.newTestRequests(s, matchingTests)
if len(tests) == 0 {
log.Warn().Msgf("Could not find local tests matching patterns (%v). See https://github.com/saucelabs/saucectl-apix-example/blob/main/docs/README.md for more details.", s.TestMatch)
log.Warn().Msgf("Could not open local tests matching patterns (%v). See https://github.com/saucelabs/saucectl-apix-example/blob/main/docs/README.md for more details.", s.TestMatch)
return 0
}

Expand Down
14 changes: 7 additions & 7 deletions internal/apitest/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func Test_findTests(t *testing.T) {
}
}

func Test_loadTest(t *testing.T) {
func Test_newTestRequest(t *testing.T) {
dir := createTestDirs(t)
defer dir.Remove()

Expand Down Expand Up @@ -271,13 +271,13 @@ func Test_loadTest(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := loadTest(tt.args.testDir, tt.args.suiteName, tt.args.testName, tt.args.tags, nil)
got, err := newTestRequest(tt.args.testDir, tt.args.suiteName, tt.args.testName, tt.args.tags, nil)
if (err != nil) != tt.wantErr {
t.Errorf("loadTest() error = %v, wantErr %v", err, tt.wantErr)
t.Errorf("newTestRequest() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("loadTest() got = %v, want %v", got, tt.want)
t.Errorf("newTestRequest() got = %v, want %v", got, tt.want)
}
})
}
Expand Down Expand Up @@ -333,7 +333,7 @@ func Test_buildTestName(t *testing.T) {
}
}

func TestRunner_loadTests(t *testing.T) {
func TestRunner_newTestRequests(t *testing.T) {
dir := createTestDirs(t)
defer dir.Remove()

Expand Down Expand Up @@ -374,8 +374,8 @@ func TestRunner_loadTests(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := r.loadTests(tt.args.s, tt.args.tests); !reflect.DeepEqual(got, tt.want) {
t.Errorf("loadTests() = %v, want %v", got, tt.want)
if got := r.newTestRequests(tt.args.s, tt.args.tests); !reflect.DeepEqual(got, tt.want) {
t.Errorf("newTestRequests() = %v, want %v", got, tt.want)
}
})
}
Expand Down

0 comments on commit 026fdd1

Please sign in to comment.