...

Source file src/edge-infra.dev/test/framework/context_test.go

Documentation: edge-infra.dev/test/framework

     1  package framework
     2  
     3  import (
     4  	"path/filepath"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestCommaSeparatedValueParsing(t *testing.T) {
    11  	tcs := map[string]struct {
    12  		input    string
    13  		expected map[string]string
    14  	}{
    15  		"typical":                {"label1=foo,bar=2", map[string]string{"label1": "foo", "bar": "2"}},
    16  		"all-commas":             {",,,", map[string]string{}},
    17  		"trailing-empty-comma":   {"foo=bar,,", map[string]string{"foo": "bar"}},
    18  		"trailing-missing-value": {"foo=bar,k", map[string]string{"foo": "bar"}},
    19  	}
    20  
    21  	for name, tc := range tcs {
    22  		t.Run(name, func(t *testing.T) {
    23  			assert.Equal(t, tc.expected, commaSepValues(tc.input))
    24  		})
    25  	}
    26  }
    27  
    28  func TestResolvePath(t *testing.T) {
    29  	Context.RepoRoot = "/Users/swim/dev/ncr/edge-infra"
    30  	assert.Equal(t, filepath.Join(Context.RepoRoot, "key.json"), ResolvePath("key.json"))
    31  
    32  	Context.RepoRoot = ""
    33  	assert.Panics(t, func() { ResolvePath("key.json") })
    34  }
    35  

View as plain text