summaryrefslogtreecommitdiff
path: root/pkg/specgenutil/ports_test.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-04-26 02:47:15 -0400
committerGitHub <noreply@github.com>2022-04-26 02:47:15 -0400
commit913a3a813c168b47f982bb6851a0968858946f85 (patch)
tree4a699f655b4f2164736633e43226bc58700cc89d /pkg/specgenutil/ports_test.go
parent05bdb4139a02eb35220c23b8ae8fe355f6d91406 (diff)
parentecd245d8fdfd9f611bd23cebf93c2c23914e5653 (diff)
downloadpodman-913a3a813c168b47f982bb6851a0968858946f85.tar.gz
podman-913a3a813c168b47f982bb6851a0968858946f85.tar.bz2
podman-913a3a813c168b47f982bb6851a0968858946f85.zip
Merge pull request #14006 from baude/pkgsignalspecgenutilunittests
Unit tests for pkg/specgenutil pkg/signal
Diffstat (limited to 'pkg/specgenutil/ports_test.go')
-rw-r--r--pkg/specgenutil/ports_test.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/pkg/specgenutil/ports_test.go b/pkg/specgenutil/ports_test.go
new file mode 100644
index 000000000..3f62c619c
--- /dev/null
+++ b/pkg/specgenutil/ports_test.go
@@ -0,0 +1,57 @@
+package specgenutil
+
+import "testing"
+
+func Test_verifyExpose(t *testing.T) {
+ type args struct {
+ expose []string
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr bool
+ }{
+ {
+ name: "single port with tcp",
+ args: args{
+ expose: []string{"53/tcp"},
+ },
+ wantErr: false,
+ },
+ {
+ name: "single port with udp",
+ args: args{
+ expose: []string{"53/udp"},
+ },
+ wantErr: false,
+ },
+ {
+ name: "good port range",
+ args: args{
+ expose: []string{"100-133"},
+ },
+ wantErr: false,
+ },
+ {
+ name: "high to low should fail",
+ args: args{
+ expose: []string{"100-99"},
+ },
+ wantErr: true,
+ },
+ {
+ name: "range with protocol",
+ args: args{
+ expose: []string{"53/tcp-55/tcp"},
+ },
+ wantErr: false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if err := verifyExpose(tt.args.expose); (err != nil) != tt.wantErr {
+ t.Errorf("verifyExpose() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ })
+ }
+}