From 3b0e3f6919a21a50127097d30b8ca561004a9590 Mon Sep 17 00:00:00 2001 From: Guillaume de Rouville Date: Thu, 26 Aug 2021 12:14:17 +0200 Subject: [PATCH] Move private repository tests + implement env helper function Signed-off-by: Guillaume de Rouville --- stdlib/universe.bats | 5 ---- tests/helpers.bash | 7 +++++ tests/ops.bats | 4 +++ .../.dagger/env/op-fetch-git/.gitignore | 2 ++ .../.dagger/env/op-fetch-git/values.yaml | 26 +++++++++++++++++++ .../fetch-git/private-repo/cue.mod/module.cue | 1 + .../private-repo/cue.mod/pkg/.gitignore | 2 ++ .../ops/fetch-git/private-repo}/fetch-git.cue | 0 8 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 tests/ops/fetch-git/private-repo/.dagger/env/op-fetch-git/.gitignore create mode 100644 tests/ops/fetch-git/private-repo/.dagger/env/op-fetch-git/values.yaml create mode 100644 tests/ops/fetch-git/private-repo/cue.mod/module.cue create mode 100644 tests/ops/fetch-git/private-repo/cue.mod/pkg/.gitignore rename {stdlib/dagger/op/tests/fetch-git => tests/ops/fetch-git/private-repo}/fetch-git.cue (100%) diff --git a/stdlib/universe.bats b/stdlib/universe.bats index 153e64ba..68b7136f 100644 --- a/stdlib/universe.bats +++ b/stdlib/universe.bats @@ -8,11 +8,6 @@ setup() { dagger -e sanity-check up } -@test "op-fetch-git" { - # This test should be in `tests/ops.bats` but dagger compute doesn't handle `dagger.#Secret` - dagger -e op-fetch-git up -} - @test "os" { dagger -e os up } diff --git a/tests/helpers.bash b/tests/helpers.bash index 9bbd96e0..c522faf3 100644 --- a/tests/helpers.bash +++ b/tests/helpers.bash @@ -26,6 +26,13 @@ dagger_new_with_plan() { "$DAGGER" new "$name" } +dagger_new_with_env() { + local sourcePlan="$1" + + "$DAGGER" init -w "$DAGGER_WORKSPACE" + rsync -av "$sourcePlan"/ "$DAGGER_WORKSPACE" +} + # dagger helper to execute the right binary dagger() { "${DAGGER}" "$@" diff --git a/tests/ops.bats b/tests/ops.bats index f2f21b59..b139dc81 100644 --- a/tests/ops.bats +++ b/tests/ops.bats @@ -108,6 +108,10 @@ setup() { run "$DAGGER" compute "$TESTDIR"/ops/fetch-git/gitdir assert_success + dagger_new_with_env "$TESTDIR"/ops/fetch-git/private-repo + run "$DAGGER" up -e op-fetch-git + assert_success + # FIXME: distinguish missing inputs from incorrect config # run "$DAGGER" compute "$TESTDIR"/ops/fetch-git/invalid # assert_failure diff --git a/tests/ops/fetch-git/private-repo/.dagger/env/op-fetch-git/.gitignore b/tests/ops/fetch-git/private-repo/.dagger/env/op-fetch-git/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/tests/ops/fetch-git/private-repo/.dagger/env/op-fetch-git/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/tests/ops/fetch-git/private-repo/.dagger/env/op-fetch-git/values.yaml b/tests/ops/fetch-git/private-repo/.dagger/env/op-fetch-git/values.yaml new file mode 100644 index 00000000..6931f4c3 --- /dev/null +++ b/tests/ops/fetch-git/private-repo/.dagger/env/op-fetch-git/values.yaml @@ -0,0 +1,26 @@ +plan: + package: . +name: op-fetch-git +inputs: + TestPAT: + secret: ENC[AES256_GCM,data:TVMwgMe+Q/BzQ/rxKIr9lRPuu2FpVQXppufy33lWQ8An+c9cTSVLCQ==,iv:Xpe54Llfcu1aTWkzNxUtcRrrqIlI/i4pdshOCVKeREY=,tag:Ugwzcpmddzhq62gPKpAkkQ==,type:str] +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBoamxhWnpyQzJRcE9TRldj + Rmd6eHV5TnpReENzNHI3MFZRZWpqaGJoRzFjClMyQW1raVNiSU84blhhSzRja01F + cjVpVmxJS1o0NEdlTXYvQ290Rjdma0kKLS0tIDkrTjRHTEtaaDY2QzhBaVJYRjhn + OXA2TkFjYlVNMFFEblA2MUZRWVB3T3MKhunM53KD+jGvdAInPbr+N6YrpirLIp4V + seb6c4bryHPL+zZWSX1H04sCWgGOypLfYq/fUyPOunbs/b+AWn8chw== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-08-26T09:34:51Z" + mac: ENC[AES256_GCM,data:JUo5COutVZMqJN2UNhqL842hhGsMdCLOFFo5g4HDFMQLG3M1iQ2M0i8AjnAlPGMukNoF3qr/rTf6FCNdpeXc/oXiOM+q0w9xp+jGup5uplhXUWw+au4YHXbSezxCVtmKCRIzkDBiN5x2zKLg7qBzsqKdzyeBiBI/QAPCoXuTk4g=,iv:m4GKvZ8g4dniAbTnUO+wjZlYx6uCJcCwkanoAzjciuY=,tag:vUUHFcGg5OIjDHeI0B+RGw==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/tests/ops/fetch-git/private-repo/cue.mod/module.cue b/tests/ops/fetch-git/private-repo/cue.mod/module.cue new file mode 100644 index 00000000..f8af9cef --- /dev/null +++ b/tests/ops/fetch-git/private-repo/cue.mod/module.cue @@ -0,0 +1 @@ +module: "" diff --git a/tests/ops/fetch-git/private-repo/cue.mod/pkg/.gitignore b/tests/ops/fetch-git/private-repo/cue.mod/pkg/.gitignore new file mode 100644 index 00000000..a572e9ee --- /dev/null +++ b/tests/ops/fetch-git/private-repo/cue.mod/pkg/.gitignore @@ -0,0 +1,2 @@ +# dagger universe +alpha.dagger.io diff --git a/stdlib/dagger/op/tests/fetch-git/fetch-git.cue b/tests/ops/fetch-git/private-repo/fetch-git.cue similarity index 100% rename from stdlib/dagger/op/tests/fetch-git/fetch-git.cue rename to tests/ops/fetch-git/private-repo/fetch-git.cue