-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
147 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package extension | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"k8s.io/apimachinery/pkg/util/sets" | ||
|
||
et "github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests" | ||
) | ||
|
||
func TestExtension_FindRemovedTestsWithoutRename(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
old et.ExtensionTestSpecs | ||
new et.ExtensionTestSpecs | ||
obsoleteTests []string | ||
want []string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "allows a test to be renamed", | ||
old: et.ExtensionTestSpecs{ | ||
{ | ||
Name: "this test has a tpyo", | ||
}, | ||
}, | ||
new: et.ExtensionTestSpecs{ | ||
{ | ||
Name: "this test doesn't have a typo", | ||
OtherNames: sets.New[string]("this test has a tpyo"), | ||
}, | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "fails when a test is removed", | ||
old: et.ExtensionTestSpecs{ | ||
{ | ||
Name: "this test was deleted", | ||
}, | ||
}, | ||
new: et.ExtensionTestSpecs{}, | ||
want: []string{"this test was deleted"}, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "succeeds when a test is removed and it's marked obsolete", | ||
old: et.ExtensionTestSpecs{ | ||
{ | ||
Name: "this test was deleted", | ||
}, | ||
}, | ||
new: et.ExtensionTestSpecs{}, | ||
obsoleteTests: []string{"this test was deleted"}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "fails when a test is renamed without other names", | ||
old: et.ExtensionTestSpecs{ | ||
{ | ||
Name: "this test has a tpyo", | ||
}, | ||
}, | ||
new: et.ExtensionTestSpecs{ | ||
{ | ||
Name: "this test doesn't have a typo", | ||
}, | ||
}, | ||
want: []string{"this test has a tpyo"}, | ||
wantErr: true, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
ext := NewExtension("openshift", "testing", "dummy") | ||
ext.AddSpecs(tt.new) | ||
ext.IgnoreObsoleteTests(tt.obsoleteTests...) | ||
|
||
got, err := ext.FindRemovedTestsWithoutRename(tt.old) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("FindRemovedTestsWithoutRename() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("FindRemovedTestsWithoutRename() got = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package extensiontests | ||
package extension | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters