package autopath import ( "os" "reflect" "strings" "testing" "github.com/coredns/coredns/plugin/test" "github.com/mholt/caddy" ) func TestSetupAutoPath(t *testing.T) { resolv, rm, err := test.TempFile(os.TempDir(), resolvConf) if err != nil { t.Fatalf("Could not create resolv.conf test file %s: %s", resolvConf, err) } defer rm() tests := []struct { input string shouldErr bool expectedZone string expectedMw string // expected plugin. expectedSearch []string // expected search path expectedErrContent string // substring from the expected error. Empty for positive cases. }{ // positive {`autopath @kubernetes`, false, "", "kubernetes", nil, ""}, {`autopath example.org @kubernetes`, false, "example.org.", "kubernetes", nil, ""}, {`autopath 10.0.0.0/8 @kubernetes`, false, "10.in-addr.arpa.", "kubernetes", nil, ""}, {`autopath ` + resolv, false, "", "", []string{"bar.com.", "baz.com.", ""}, ""}, // negative {`autopath kubernetes`, true, "", "", nil, "open kubernetes: no such file or directory"}, {`autopath`, true, "", "", nil, "no resolv-conf"}, } for i, test := range tests { c := caddy.NewTestController("dns", test.input) ap, mw, err := autoPathParse(c) if test.shouldErr && err == nil { t.Errorf("Test %d: Expected error but found %s for input %s", i, err, test.input) } if err != nil { if !test.shouldErr { t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) } if !strings.Contains(err.Error(), test.expectedErrContent) { t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) } } if !test.shouldErr && mw != test.expectedMw { t.Errorf("Test %d, Plugin not correctly set for input %s. Expected: %s, actual: %s", i, test.input, test.expectedMw, mw) } if !test.shouldErr && ap.search != nil { if !reflect.DeepEqual(test.expectedSearch, ap.search) { t.Errorf("Test %d, wrong searchpath for input %s. Expected: '%v', actual: '%v'", i, test.input, test.expectedSearch, ap.search) } } if !test.shouldErr && test.expectedZone != "" { if test.expectedZone != ap.Zones[0] { t.Errorf("Test %d, expected zone %q for input %s, got: %q", i, test.expectedZone, test.input, ap.Zones[0]) } } } } const resolvConf = `nameserver 1.2.3.4 domain foo.com search bar.com baz.com options ndots:5 ` -for-next-branch'>ci/workflow-for-next-branch Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/packages/astro/test/fixtures/static-build-frameworks/astro.config.mjs (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-04-26Revert "fix: replace serialize-javascript & random-bytes with custom internal...Gravatar Nate Moore 7-565/+215
2022-04-26[ci] formatGravatar okikio 2-271/+315
2022-04-26fix: replace serialize-javascript & random-bytes with custom internal modulesGravatar Okiki 7-215/+521
2022-04-26[ci] release (#3182)create-astro@0.10.0astro@1.0.0-beta.18@astrojs/vercel@0.1.4@astrojs/tailwind@0.2.1@astrojs/svelte@0.1.2@astrojs/netlify@0.3.3Gravatar github-actions[bot] 54-146/+130
2022-04-26[ci] formatGravatar matthewp 1-1/+1
2022-04-26fix(vercel): `trailingSlash` fix for non-html pages (#3185)Gravatar Juan Martín Seery 2-29/+42
2022-04-26Prevent watcher from running during the build (#3207)Gravatar Matthew Phillips 2-0/+9
2022-04-26Fix lockfile (#3210)Gravatar Juan Martín Seery 1-6/+0
2022-04-26Add missing is:raw in AstroBuiltinAttributes (#3209)Gravatar Erika 2-0/+6
2022-04-26Feat: support `astro add` without npm installing (#3183)Gravatar Ben Holmes 6-30/+49
2022-04-26Add Astro attributes to svg elements (#3205)Gravatar Erika 2-1/+9
2022-04-26[ci] formatGravatar bholmesdev 2-9/+9
2022-04-26Feat: `create astro` add install step (#3190)Gravatar Ben Holmes 7-162/+299
2022-04-26[ci] collect statsGravatar FredKSchott 1-0/+1
2022-04-25fix(markdown): file.url fixes (#3198)Gravatar Juan Martín Seery 11-10/+149
2022-04-25[ci] collect statsGravatar FredKSchott 1-0/+1
2022-04-24add vite to licenseGravatar Fred K. Schott 2-24/+29
2022-04-24feat(markdown): Improved types (#3191)Gravatar Juan Martín Seery 3-6/+47
2022-04-24[ci] collect statsGravatar FredKSchott 1-0/+1
2022-04-23[ci] collect statsGravatar FredKSchott 1-0/+1