github.com/drone/go-convert@v0.0.0-20240307072510-6bd371c65e61/convert/circle/internal/orbs/localstack/localstack_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 localstack
    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 TestWait(t *testing.T) {
    27  	in := &circle.Custom{
    28  		Params: map[string]interface{}{},
    29  	}
    30  
    31  	got := Convert("wait", in)
    32  	want := &harness.Step{
    33  		Name: "localstack_wait",
    34  		Type: "script",
    35  		Spec: &harness.StepExec{
    36  			Run: "sleep 10",
    37  		},
    38  	}
    39  
    40  	if diff := cmp.Diff(got, want); diff != "" {
    41  		t.Errorf("Unexpected orb conversion")
    42  		t.Log(diff)
    43  	}
    44  }
    45  
    46  func TestStart(t *testing.T) {
    47  	in := &circle.Custom{
    48  		Params: map[string]interface{}{},
    49  	}
    50  
    51  	got := Convert("start", in)
    52  	want := &harness.Step{
    53  		Name: "localstack",
    54  		Type: "background",
    55  		Spec: &harness.StepBackground{
    56  			Image: "localstack/localstack",
    57  			Ports: []string{"4566"},
    58  		},
    59  	}
    60  
    61  	if diff := cmp.Diff(got, want); diff != "" {
    62  		t.Errorf("Unexpected orb conversion")
    63  		t.Log(diff)
    64  	}
    65  }
    66  
    67  func TestUnknownCommand(t *testing.T) {
    68  	if Convert("unknown", nil) != nil {
    69  		t.Errorf("Expect unknown command returns nil step")
    70  	}
    71  }