diff options
Diffstat (limited to 'plugin/auto/setup_test.go')
-rw-r--r-- | plugin/auto/setup_test.go | 67 |
1 files changed, 25 insertions, 42 deletions
diff --git a/plugin/auto/setup_test.go b/plugin/auto/setup_test.go index bc6b94f37..3ea50eb99 100644 --- a/plugin/auto/setup_test.go +++ b/plugin/auto/setup_test.go @@ -15,7 +15,6 @@ func TestAutoParse(t *testing.T) { expectedTempl string expectedRe string expectedReloadInterval time.Duration - expectedDuration time.Duration expectedTo []string }{ { @@ -23,46 +22,33 @@ func TestAutoParse(t *testing.T) { directory /tmp transfer to 127.0.0.1 }`, - false, "/tmp", "${1}", `db\.(.*)`, 60 * time.Second, 60 * time.Second, []string{"127.0.0.1:53"}, + false, "/tmp", "${1}", `db\.(.*)`, 60 * time.Second, []string{"127.0.0.1:53"}, }, { `auto 10.0.0.0/24 { directory /tmp }`, - false, "/tmp", "${1}", `db\.(.*)`, 60 * time.Second, 60 * time.Second, nil, + false, "/tmp", "${1}", `db\.(.*)`, 60 * time.Second, nil, }, { `auto { directory /tmp - no_reload + reload 0 }`, - false, "/tmp", "${1}", `db\.(.*)`, 0 * time.Second, 0 * time.Second, nil, + false, "/tmp", "${1}", `db\.(.*)`, 0 * time.Second, nil, }, { `auto { directory /tmp (.*) bliep }`, - false, "/tmp", "bliep", `(.*)`, 60 * time.Second, 60 * time.Second, nil, - }, - { - `auto { - directory /tmp (.*) bliep 10 - }`, - false, "/tmp", "bliep", `(.*)`, 10 * time.Second, 10 * time.Second, nil, + false, "/tmp", "bliep", `(.*)`, 60 * time.Second, nil, }, { `auto { directory /tmp (.*) bliep reload 10s }`, - false, "/tmp", "bliep", `(.*)`, 10 * time.Second, 10 * time.Second, nil, - }, - { - `auto { - directory /tmp (.*) bliep 20 - reload 10s - }`, - false, "/tmp", "bliep", `(.*)`, 10 * time.Second, 20 * time.Second, nil, + false, "/tmp", "bliep", `(.*)`, 10 * time.Second, nil, }, { `auto { @@ -71,44 +57,44 @@ func TestAutoParse(t *testing.T) { transfer to 127.0.0.2 upstream 8.8.8.8 }`, - false, "/tmp", "bliep", `(.*)`, 60 * time.Second, 60 * time.Second, []string{"127.0.0.1:53", "127.0.0.2:53"}, + false, "/tmp", "bliep", `(.*)`, 60 * time.Second, []string{"127.0.0.1:53", "127.0.0.2:53"}, }, // errors + // NO_RELOAD has been deprecated. { - `auto example.org { - directory - }`, - true, "", "${1}", `db\.(.*)`, 60 * time.Second, 60 * time.Second, nil, - }, - { - `auto example.org { - directory /tmp * {1} + `auto { + directory /tmp + no_reload }`, - true, "", "${1}", ``, 60 * time.Second, 60 * time.Second, nil, + true, "/tmp", "${1}", `db\.(.*)`, 0 * time.Second, nil, }, + // TIMEOUT has been deprecated. { - `auto example.org { - directory /tmp * {1} aa + `auto { + directory /tmp (.*) bliep 10 }`, - true, "", "${1}", ``, 60 * time.Second, 60 * time.Second, nil, + true, "/tmp", "bliep", `(.*)`, 10 * time.Second, nil, }, + // no directory specified. { `auto example.org { - directory /tmp .* {1} + directory }`, - true, "", "${1}", ``, 60 * time.Second, 60 * time.Second, nil, + true, "", "${1}", `db\.(.*)`, 60 * time.Second, nil, }, + // illegal REGEXP. { `auto example.org { - directory /tmp .* {1} + directory /tmp * {1} }`, - true, "", "${1}", ``, 60 * time.Second, 60 * time.Second, nil, + true, "/tmp", "${1}", ``, 60 * time.Second, nil, }, + // unexpected argument. { `auto example.org { - directory /tmp .* {1} + directory /tmp (.*) {1} aa }`, - true, "", "${1}", ``, 60 * time.Second, 60 * time.Second, nil, + true, "/tmp", "${1}", ``, 60 * time.Second, nil, }, } @@ -133,9 +119,6 @@ func TestAutoParse(t *testing.T) { if a.loader.ReloadInterval != test.expectedReloadInterval { t.Fatalf("Test %d expected %v, got %v", i, test.expectedReloadInterval, a.loader.ReloadInterval) } - if a.loader.duration != test.expectedDuration { - t.Fatalf("Test %d expected %v, got %v", i, test.expectedDuration, a.loader.duration) - } if test.expectedTo != nil { for j, got := range a.loader.transferTo { if got != test.expectedTo[j] { |