github.com/drone/go-convert@v0.0.0-20240307072510-6bd371c65e61/convert/circle/internal/orbs/saucelabs/saucelabs_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 saucelabs
    16  
    17  import (
    18  	"testing"
    19  
    20  	circle "github.com/drone/go-convert/convert/circle/yaml"
    21  	harness "github.com/drone/spec/dist/go"
    22  
    23  	"github.com/google/go-cmp/cmp"
    24  )
    25  
    26  func TestRun(t *testing.T) {
    27  	in := &circle.Custom{
    28  		Params: map[string]interface{}{
    29  			"sauce-username":   "janecitizen",
    30  			"sauce-access-key": "topsecret",
    31  		},
    32  	}
    33  
    34  	got := Convert("saucectl-run", in)
    35  	want := &harness.Step{
    36  		Name: "saucelabs",
    37  		Type: "background",
    38  		Spec: &harness.StepBackground{
    39  			Run: "curl -L https://saucelabs.github.io/saucectl/install | bash -s -- -b /usr/local/bin\nsaucectl",
    40  			Envs: map[string]string{
    41  				"SAUCE_ACCESS_KEY": "topsecret",
    42  				"SAUCE_USERNAME":   "janecitizen",
    43  			},
    44  		},
    45  	}
    46  
    47  	if diff := cmp.Diff(got, want); diff != "" {
    48  		t.Errorf("Unexpected orb conversion")
    49  		t.Log(diff)
    50  	}
    51  }
    52  
    53  func TestUnknownCommand(t *testing.T) {
    54  	if Convert("unknown", nil) != nil {
    55  		t.Errorf("Expect unknown command returns nil step")
    56  	}
    57  }