Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: Joel Longtine <joel@dagger.io>
  • Loading branch information
jlongtine committed Mar 10, 2022
1 parent b3ac2b7 commit 43b9df7
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/dagger/cmd/do.go
Expand Up @@ -130,7 +130,13 @@ func doHelp(cmd *cobra.Command, _ []string) {

p, err := loadPlan()
if err != nil {
errorMsg = "Error: failed to load plan\n\n"
errstring := err.Error()
if strings.Contains(errstring, "cannot find package") && strings.Contains(errstring, "alpha.dagger.io") {
errorMsg = "Attempting to load a dagger 0.1.0 project. Please upgrade your config to be compatible with this version of dagger. Contact the Dagger team if you need help!\n\n"
// lg.Fatal().Msg("Attempting to load a dagger 0.1.0 project. Please upgrade your config to be compatible with this version of dagger. Contact the Dagger team if you need help!")
} else {
errorMsg = "Error: failed to load plan\n\n"
}
} else {
loadedMsg = "Plan loaded from " + planPath
actionLookupPath := getTargetPath(cmd.Flags().Args())
Expand Down
5 changes: 5 additions & 0 deletions tests/plan.bats
Expand Up @@ -38,6 +38,11 @@ setup() {
refute_output --partial 'client.filesystem."./dependent_do".write'
}

@test "plan/do: Nice error message for 0.1.0 projects" {
run "$DAGGER" "do" -p ./plan/do/error_message_for_0.1_projects.cue
assert_output --partial "Attempting to load a 0.1.0 plan."
}

@test "plan/hello" {
# Europa loader handles the cwd differently, therefore we need to CD into the tree at or below the parent of cue.mod
cd "$TESTDIR"
Expand Down
60 changes: 60 additions & 0 deletions tests/plan/do/error_message_for_0.1_projects.cue
@@ -0,0 +1,60 @@
package main

import (
"alpha.dagger.io/dagger"
"alpha.dagger.io/aws/s3"
"alpha.dagger.io/netlify"
"alpha.dagger.io/os"
)

repo: dagger.#Artifact & dagger.#Input

hello: {

dir: dagger.#Artifact & dagger.#Input

ctr: os.#Container & {
command: """
ls -l /src > /tmp/out
"""
mount: "/src": from: dir
}

f: os.#File & {
from: ctr
path: "/tmp/out"
}

message: f.contents & dagger.#Output
}

// Website
web: {
source: os.#Dir & {
from: repo
path: "web"
}

url: string & dagger.#Output

// Where to host the website?
provider: *"s3" | "netlify" & dagger.#Input

// Deploy to AWS S3
if provider == "s3" {
url: "\(bucket.url)index.html"
bucket: s3.#Put & {
contentType: "text/html"
"source": source
}
}

// Deploy to Netlify
if provider == "netlify" {
url: site.url

site: netlify.#Site & {
contents: source
}
}
}

0 comments on commit 43b9df7

Please sign in to comment.