-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: test management optimization (#268)
Co-authored-by: jzli <[email protected]>
- Loading branch information
Showing
6 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -17,6 +17,9 @@ limitations under the License. | |
package v1alpha1 | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
authv1 "k8s.io/api/authorization/v1" | ||
|
@@ -34,3 +37,74 @@ var _ = Describe("TestCaseExecution", func() { | |
}) | ||
}) | ||
}) | ||
|
||
func Test_executorFromNote(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
note string | ||
want *UserSpec | ||
}{ | ||
{ | ||
name: "empty string", | ||
note: "", | ||
want: nil, | ||
}, | ||
{ | ||
name: "invalid string format", | ||
note: "xxxxxx", | ||
want: nil, | ||
}, | ||
{ | ||
name: "invalid user string", | ||
note: "[createdBy: xxx!!!xxx]", | ||
want: nil, | ||
}, | ||
{ | ||
name: "valid user string", | ||
note: "[createdBy: xxx|[email protected]]", | ||
want: &UserSpec{ | ||
Name: "xxx", | ||
Email: "[email protected]", | ||
}, | ||
}, | ||
{ | ||
name: "allow email is not valid", | ||
note: "[createdBy: xxx|xxxxx]", | ||
want: &UserSpec{ | ||
Name: "xxx", | ||
Email: "xxxxx", | ||
}, | ||
}, | ||
{ | ||
name: "allow email is empty", | ||
note: "[createdBy: xxx|]", | ||
want: &UserSpec{ | ||
Name: "xxx", | ||
Email: "", | ||
}, | ||
}, | ||
{ | ||
name: "allow both is empty", | ||
note: "[createdBy: |]", | ||
want: &UserSpec{ | ||
Name: "", | ||
Email: "", | ||
}, | ||
}, | ||
{ | ||
name: "allow both is empty", | ||
note: "[createdBy: xiangmu@._-|xiangmu@-._]", | ||
want: &UserSpec{ | ||
Name: "xiangmu@._-", | ||
Email: "xiangmu@-._", | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := UserSpecFromNote(tt.note); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("UserSpecFromNote() = %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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.