31 lines
541 B
Go
31 lines
541 B
Go
package podmancontainer
|
|
|
|
import (
|
|
"net/url"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSpecFromURL(t *testing.T) {
|
|
cases := map[string]*Spec{
|
|
"podman-container://containername": {
|
|
Container: "containername",
|
|
},
|
|
"podman-container://": nil,
|
|
}
|
|
for s, expected := range cases {
|
|
u, err := url.Parse(s)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
got, err := SpecFromURL(u)
|
|
if expected != nil {
|
|
require.NoError(t, err)
|
|
require.EqualValues(t, expected, got, s)
|
|
} else {
|
|
require.Error(t, err, s)
|
|
}
|
|
}
|
|
}
|