github.com/drone/go-convert@v0.0.0-20240307072510-6bd371c65e61/convert/circle/internal/orbs/coveralls/coveralls_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 coveralls 16 17 import ( 18 "strings" 19 "testing" 20 21 circle "github.com/drone/go-convert/convert/circle/yaml" 22 harness "github.com/drone/spec/dist/go" 23 24 "github.com/google/go-cmp/cmp" 25 ) 26 27 func TestUpload(t *testing.T) { 28 in := &circle.Custom{ 29 Params: map[string]interface{}{ 30 "token": "SECRET", 31 }, 32 } 33 34 got := Convert("upload", in) 35 want := &harness.Step{ 36 Name: "coveralls", 37 Type: "script", 38 Spec: &harness.StepExec{ 39 Envs: map[string]string{"COVERALLS_REPO_TOKEN": "SECRET"}, 40 Run: strings.Join( 41 []string{ 42 "curl -sLO https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-linux.tar.gz", 43 "tar -xzf coveralls-linux.tar.gz", 44 "./coveralls", 45 }, "\n", 46 ), 47 }, 48 } 49 50 if diff := cmp.Diff(got, want); diff != "" { 51 t.Errorf("Unexpected orb conversion") 52 t.Log(diff) 53 } 54 } 55 56 func TestUnknownCommand(t *testing.T) { 57 if Convert("unknown", nil) != nil { 58 t.Errorf("Expect unknown command returns nil step") 59 } 60 }