From 6a8f45123a02ccd3231997eb57beb04edc2bda4c Mon Sep 17 00:00:00 2001 From: hbdgr Date: Thu, 4 Jul 2019 16:28:09 +0200 Subject: [PATCH] test for snapshotTimeout option --- builder/digitalocean/builder_test.go | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/builder/digitalocean/builder_test.go b/builder/digitalocean/builder_test.go index 9ef7c0ad7..70ec6fea9 100644 --- a/builder/digitalocean/builder_test.go +++ b/builder/digitalocean/builder_test.go @@ -190,7 +190,46 @@ func TestBuilderPrepare_StateTimeout(t *testing.T) { if err == nil { t.Fatal("should have error") } +} +func TestBuilderPrepare_SnapshotTimeout(t *testing.T) { + var b Builder + config := testConfig() + + // Test default + warnings, err := b.Prepare(config) + if len(warnings) > 0 { + t.Fatalf("bad: %#v", warnings) + } + if err != nil { + t.Fatalf("should not have error: %s", err) + } + + if b.config.SnapshotTimeout != 60*time.Minute { + t.Errorf("invalid: %s", b.config.SnapshotTimeout) + } + + // Test set + config["snapshot_timeout"] = "15m" + b = Builder{} + warnings, err = b.Prepare(config) + if len(warnings) > 0 { + t.Fatalf("bad: %#v", warnings) + } + if err != nil { + t.Fatalf("should not have error: %s", err) + } + + // Test bad + config["snapshot_timeout"] = "badstring" + b = Builder{} + warnings, err = b.Prepare(config) + if len(warnings) > 0 { + t.Fatalf("bad: %#v", warnings) + } + if err == nil { + t.Fatal("should have error") + } } func TestBuilderPrepare_PrivateNetworking(t *testing.T) {