github.com/drone/go-convert@v0.0.0-20240307072510-6bd371c65e61/convert/jenkins/option_test.go (about) 1 // Copyright 2022 Harness, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package jenkins 16 17 import "testing" 18 19 func TestOptions(t *testing.T) { 20 p := New( 21 WithDockerhub("account.docker"), 22 WithKubernetes("namespace", "connector.kubernetes"), 23 WithAttempts(5), 24 WithToken("dummy-da39a3ee5e6b4b0d3255bfef95601890afd80709"), 25 ) 26 27 if got, want := p.kubeConnector, "connector.kubernetes"; got != want { 28 t.Errorf("Want kubernetes connector %q, got %q", want, got) 29 } 30 if got, want := p.kubeNamespace, "namespace"; got != want { 31 t.Errorf("Want kubernetes namespace %q, got %q", want, got) 32 } 33 if got, want := p.kubeEnabled, true; got != want { 34 t.Errorf("Want kubernetes enabled %v, got %v", want, got) 35 } 36 if got, want := p.dockerhubConn, "account.docker"; got != want { 37 t.Errorf("Want docker connector %q, got %q", want, got) 38 } 39 if got, want := p.attempts, 5; got != want { 40 t.Errorf("Want attempts %v, got %v", want, got) 41 } 42 if got, want := p.token, "dummy-da39a3ee5e6b4b0d3255bfef95601890afd80709"; got != want { 43 t.Errorf("Want token %q, got %q", want, got) 44 } 45 46 } 47 48 func TestOptions_Defaults(t *testing.T) { 49 p := New() 50 51 if got, want := p.kubeConnector, ""; got != want { 52 t.Errorf("Want kubernetes connector %q, got %q", want, got) 53 } 54 if got, want := p.kubeNamespace, "default"; got != want { 55 t.Errorf("Want kubernetes namespace %q, got %q", want, got) 56 } 57 if got, want := p.kubeEnabled, false; got != want { 58 t.Errorf("Want kubernetes enabled %v, got %v", want, got) 59 } 60 if got, want := p.dockerhubConn, ""; got != want { 61 t.Errorf("Want docker connector %q, got %q", want, got) 62 } 63 if got, want := p.attempts, 1; got != want { 64 t.Errorf("Want attempts %v, got %v", want, got) 65 } 66 }