1
1
Fork 0
mirror of https://github.com/mcuadros/ascode synced 2024-05-08 00:26:15 +02:00

starlark: fix flaky tests

This commit is contained in:
Máximo Cuadros 2020-03-29 11:20:08 +02:00
parent f8e6cb55d2
commit 6a682e4977
No known key found for this signature in database
GPG Key ID: 17A5DFEDC735AE4B
5 changed files with 9 additions and 14 deletions

View File

@ -11,6 +11,7 @@ import (
func TestImage(t *testing.T) {
resolve.AllowFloat = true
resolve.AllowLambda = true
thread := &starlark.Thread{Load: testdata.NewLoader(LoadModule, ModuleName)}
starlarktest.SetReporter(thread, t)

View File

@ -13,21 +13,15 @@ assert.eq(image.domain, "docker.io")
assert.eq(image.path, "library/fedora")
assert.eq(image.version(), "latest")
full = docker.image("fedora", "24")
assert.eq(full.name, "docker.io/library/fedora")
assert.eq(full.version(True), "docker.io/library/fedora:24")
semver = docker.image("fedora", ">=22 <30")
assert.eq(semver.name, "docker.io/library/fedora")
assert.eq(semver.version(), "29")
assert.eq(semver.version(True), "docker.io/library/fedora:29")
golang = docker.image("golang", "1.2.x")
assert.eq(golang.name, "docker.io/library/golang")
assert.eq(golang.version(), "1.2.2")
prometheus = docker.image("quay.io/prometheus/prometheus", "1.8.x")
assert.eq(prometheus.name, "quay.io/prometheus/prometheus")
assert.eq(prometheus.version(), "v1.8.2")
tagNotFound = docker.image("fedora", "not-found")
assert.eq(tagNotFound.name, "docker.io/library/fedora")
def tagNotExistant(): tagNotFound.version()
assert.fails(tagNotExistant,'tag "not-found" not found in repository')
assert.fails(lambda: tagNotFound.version(), 'tag "not-found" not found in repository')

View File

@ -42,7 +42,7 @@ func doTestExample(t *testing.T, filename string) {
doTestPrint(t, filename, printer)
expected := strings.TrimSpace(getExpectedFromExample(t, filename))
assert.Equal(t, strings.TrimSpace(output), expected)
assert.Equalf(t, strings.TrimSpace(output), expected, filename)
}
func getExpectedFromExample(t *testing.T, filename string) string {

View File

@ -1,7 +1,7 @@
# Create a new instance of the latest Ubuntu 14.04 on an
# t2.micro node with an AWS Tag naming it "HelloWorld"
aws = tf.provider("aws")
aws = tf.provider("aws", "2.54.0")
aws.region = "us-west-2"
ubuntu_filter = "ubuntu/images/*/ubuntu-xenial-16.04-amd64-server-*"

View File

@ -1,6 +1,6 @@
tf.backend = backend("gcs", bucket="tf-state")
aws = tf.provider("aws", region="us-west-2")
aws = tf.provider("aws", "2.54.0", region="us-west-2")
aws.resource.instance("foo", instance_type="t2.micro")
print(hcl(tf))