This change enables parallelism for our tests. It also introdues a `test_core` Makefile target to just run the core engine tests, and not the providers, since they take a long time. This is intended only as part of the inner developer loop.
279 lines
9.8 KiB
Go
279 lines
9.8 KiB
Go
// Licensed to Pulumi Corporation ("Pulumi") under one or more
|
|
// contributor license agreements. See the NOTICE file distributed with
|
|
// this work for additional information regarding copyright ownership.
|
|
// Pulumi licenses this file to You under the Apache License, Version 2.0
|
|
// (the "License"); you may not use this file except in compliance with
|
|
// the License. You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package pack
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/pulumi/lumi/pkg/tokens"
|
|
)
|
|
|
|
func TestPackageURLStringParse(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
{
|
|
s := "*"
|
|
pkg := tokens.PackageName("simple")
|
|
p, err := PackageURLString(s).Parse(pkg)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, pkg.String(), p.String())
|
|
assert.Equal(t, "", p.Proto)
|
|
assert.Equal(t, "", p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, "", string(p.Version))
|
|
p = p.Defaults()
|
|
assert.Equal(t, DefaultPackageURLProto, p.Proto)
|
|
assert.Equal(t, DefaultPackageURLBase, p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, DefaultPackageURLVersion, p.Version)
|
|
}
|
|
{
|
|
s := "simple"
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(s))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "", p.Proto)
|
|
assert.Equal(t, "", p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, "", string(p.Version))
|
|
p = p.Defaults()
|
|
assert.Equal(t, DefaultPackageURLProto, p.Proto)
|
|
assert.Equal(t, DefaultPackageURLBase, p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, DefaultPackageURLVersion, p.Version)
|
|
}
|
|
{
|
|
b := "simple"
|
|
s := b + "#" + string(DefaultPackageURLVersion)
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(b))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "", p.Proto)
|
|
assert.Equal(t, "", p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, DefaultPackageURLVersion, p.Version)
|
|
p = p.Defaults()
|
|
assert.Equal(t, DefaultPackageURLProto, p.Proto)
|
|
assert.Equal(t, DefaultPackageURLBase, p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, DefaultPackageURLVersion, p.Version)
|
|
}
|
|
{
|
|
b := "simple"
|
|
s := b + "#1.0.6"
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(b))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "", p.Proto)
|
|
assert.Equal(t, "", p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, VersionSpec("1.0.6"), p.Version)
|
|
p = p.Defaults()
|
|
assert.Equal(t, DefaultPackageURLProto, p.Proto)
|
|
assert.Equal(t, DefaultPackageURLBase, p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, VersionSpec("1.0.6"), p.Version)
|
|
}
|
|
{
|
|
b := "simple"
|
|
s := b + "#>=1.0.6"
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(b))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "", p.Proto)
|
|
assert.Equal(t, "", p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, VersionSpec(">=1.0.6"), p.Version)
|
|
p = p.Defaults()
|
|
assert.Equal(t, DefaultPackageURLProto, p.Proto)
|
|
assert.Equal(t, DefaultPackageURLBase, p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, VersionSpec(">=1.0.6"), p.Version)
|
|
}
|
|
{
|
|
b := "simple"
|
|
s := b + "#6f99088"
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(b))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "", p.Proto)
|
|
assert.Equal(t, "", p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, VersionSpec("6f99088"), p.Version)
|
|
p = p.Defaults()
|
|
assert.Equal(t, DefaultPackageURLProto, p.Proto)
|
|
assert.Equal(t, DefaultPackageURLBase, p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, VersionSpec("6f99088"), p.Version)
|
|
}
|
|
{
|
|
b := "simple"
|
|
s := b + "#83030685c3b8a3dbe96bd10ab055f029667a96b0"
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(b))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "", p.Proto)
|
|
assert.Equal(t, "", p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, VersionSpec("83030685c3b8a3dbe96bd10ab055f029667a96b0"), p.Version)
|
|
p = p.Defaults()
|
|
assert.Equal(t, DefaultPackageURLProto, p.Proto)
|
|
assert.Equal(t, DefaultPackageURLBase, p.Base)
|
|
assert.Equal(t, "simple", string(p.Name))
|
|
assert.Equal(t, VersionSpec("83030685c3b8a3dbe96bd10ab055f029667a96b0"), p.Version)
|
|
}
|
|
{
|
|
s := "namespace/complex"
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(s))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "", p.Proto)
|
|
assert.Equal(t, "", p.Base)
|
|
assert.Equal(t, "namespace/complex", string(p.Name))
|
|
assert.Equal(t, "", string(p.Version))
|
|
p = p.Defaults()
|
|
assert.Equal(t, DefaultPackageURLProto, p.Proto)
|
|
assert.Equal(t, DefaultPackageURLBase, p.Base)
|
|
assert.Equal(t, "namespace/complex", string(p.Name))
|
|
assert.Equal(t, DefaultPackageURLVersion, p.Version)
|
|
}
|
|
{
|
|
s := "ns1/ns2/ns3/ns4/complex"
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(s))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "", p.Proto)
|
|
assert.Equal(t, "", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, "", string(p.Version))
|
|
p = p.Defaults()
|
|
assert.Equal(t, DefaultPackageURLProto, p.Proto)
|
|
assert.Equal(t, DefaultPackageURLBase, p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, DefaultPackageURLVersion, p.Version)
|
|
}
|
|
{
|
|
s := "_/_/_/_a-b/a0/c0Mpl3x_"
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(s))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "", p.Proto)
|
|
assert.Equal(t, "", p.Base)
|
|
assert.Equal(t, "_/_/_/_a-b/a0/c0Mpl3x_", string(p.Name))
|
|
assert.Equal(t, "", string(p.Version))
|
|
p = p.Defaults()
|
|
assert.Equal(t, DefaultPackageURLProto, p.Proto)
|
|
assert.Equal(t, DefaultPackageURLBase, p.Base)
|
|
assert.Equal(t, "_/_/_/_a-b/a0/c0Mpl3x_", string(p.Name))
|
|
assert.Equal(t, DefaultPackageURLVersion, p.Version)
|
|
}
|
|
{
|
|
b := "ns1/ns2/ns3/ns4/complex"
|
|
s := "github.com/" + b
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(b))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "", p.Proto)
|
|
assert.Equal(t, "github.com/", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, "", string(p.Version))
|
|
p = p.Defaults()
|
|
assert.Equal(t, DefaultPackageURLProto, p.Proto)
|
|
assert.Equal(t, "github.com/", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, DefaultPackageURLVersion, p.Version)
|
|
}
|
|
{
|
|
b := "ns1/ns2/ns3/ns4/complex"
|
|
s := "git://github.com/" + b
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(b))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "git://", p.Proto)
|
|
assert.Equal(t, "github.com/", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, "", string(p.Version))
|
|
p = p.Defaults()
|
|
assert.Equal(t, "git://", p.Proto)
|
|
assert.Equal(t, "github.com/", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, DefaultPackageURLVersion, p.Version)
|
|
}
|
|
{
|
|
b := "ns1/ns2/ns3/ns4/complex"
|
|
s := "git://github.com/" + b + "#1.0.6"
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(b))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "git://", p.Proto)
|
|
assert.Equal(t, "github.com/", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, VersionSpec("1.0.6"), p.Version)
|
|
p = p.Defaults()
|
|
assert.Equal(t, "git://", p.Proto)
|
|
assert.Equal(t, "github.com/", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, VersionSpec("1.0.6"), p.Version)
|
|
}
|
|
{
|
|
b := "ns1/ns2/ns3/ns4/complex"
|
|
s := "git://github.com/" + b + "#>=1.0.6"
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(b))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, s, p.String())
|
|
assert.Equal(t, "git://", p.Proto)
|
|
assert.Equal(t, "github.com/", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, VersionSpec(">=1.0.6"), p.Version)
|
|
p = p.Defaults()
|
|
assert.Equal(t, "git://", p.Proto)
|
|
assert.Equal(t, "github.com/", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, ">=1.0.6", string(p.Version))
|
|
}
|
|
{
|
|
b := "ns1/ns2/ns3/ns4/complex"
|
|
s := "git://github.com/" + b + "#6f99088"
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(b))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, "git://", p.Proto)
|
|
assert.Equal(t, "github.com/", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, VersionSpec("6f99088"), p.Version)
|
|
p = p.Defaults()
|
|
assert.Equal(t, "git://", p.Proto)
|
|
assert.Equal(t, "github.com/", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, "6f99088", string(p.Version))
|
|
}
|
|
{
|
|
b := "ns1/ns2/ns3/ns4/complex"
|
|
s := "git://github.com/" + b + "#83030685c3b8a3dbe96bd10ab055f029667a96b0"
|
|
p, err := PackageURLString(s).Parse(tokens.PackageName(b))
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, "git://", p.Proto)
|
|
assert.Equal(t, "github.com/", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, VersionSpec("83030685c3b8a3dbe96bd10ab055f029667a96b0"), p.Version)
|
|
p = p.Defaults()
|
|
assert.Equal(t, "git://", p.Proto)
|
|
assert.Equal(t, "github.com/", p.Base)
|
|
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
|
|
assert.Equal(t, "83030685c3b8a3dbe96bd10ab055f029667a96b0", string(p.Version))
|
|
}
|
|
}
|