aboutsummaryrefslogtreecommitdiff
path: root/core/coremain/run_test.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-08-19 17:14:17 -0700
committerGravatar GitHub <noreply@github.com> 2016-08-19 17:14:17 -0700
commit9ac3cab1b7b1b1e78f86ce3c6a80fbee312162e6 (patch)
tree437e9755927c33af16276ad2602a6da115f948cb /core/coremain/run_test.go
parenta1989c35231b0e5ea271b2f68d82c1a63e697cd0 (diff)
downloadcoredns-9ac3cab1b7b1b1e78f86ce3c6a80fbee312162e6.tar.gz
coredns-9ac3cab1b7b1b1e78f86ce3c6a80fbee312162e6.tar.zst
coredns-9ac3cab1b7b1b1e78f86ce3c6a80fbee312162e6.zip
Make CoreDNS a server type plugin for Caddy (#220)
* Make CoreDNS a server type plugin for Caddy Remove code we don't need and port all middleware over. Fix all tests and rework the documentation. Also make `go generate` build a caddy binary which we then copy into our directory. This means `go build`-builds remain working as-is. And new etc instances in each etcd test for better isolation. Fix more tests and rework test.Server with the newer support Caddy offers. Fix Makefile to support new mode of operation.
Diffstat (limited to 'core/coremain/run_test.go')
-rw-r--r--core/coremain/run_test.go75
1 files changed, 0 insertions, 75 deletions
diff --git a/core/coremain/run_test.go b/core/coremain/run_test.go
deleted file mode 100644
index 149dab0c1..000000000
--- a/core/coremain/run_test.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package coremain
-
-import (
- "runtime"
- "testing"
-)
-
-func TestSetCPU(t *testing.T) {
- currentCPU := runtime.GOMAXPROCS(-1)
- maxCPU := runtime.NumCPU()
- halfCPU := int(0.5 * float32(maxCPU))
- if halfCPU < 1 {
- halfCPU = 1
- }
- for i, test := range []struct {
- input string
- output int
- shouldErr bool
- }{
- {"1", 1, false},
- {"-1", currentCPU, true},
- {"0", currentCPU, true},
- {"100%", maxCPU, false},
- {"50%", halfCPU, false},
- {"110%", currentCPU, true},
- {"-10%", currentCPU, true},
- {"invalid input", currentCPU, true},
- {"invalid input%", currentCPU, true},
- {"9999", maxCPU, false}, // over available CPU
- } {
- err := setCPU(test.input)
- if test.shouldErr && err == nil {
- t.Errorf("Test %d: Expected error, but there wasn't any", i)
- }
- if !test.shouldErr && err != nil {
- t.Errorf("Test %d: Expected no error, but there was one: %v", i, err)
- }
- if actual, expected := runtime.GOMAXPROCS(-1), test.output; actual != expected {
- t.Errorf("Test %d: GOMAXPROCS was %d but expected %d", i, actual, expected)
- }
- // teardown
- runtime.GOMAXPROCS(currentCPU)
- }
-}
-
-func TestSetVersion(t *testing.T) {
- setVersion()
- if !devBuild {
- t.Error("Expected default to assume development build, but it didn't")
- }
- if got, want := appVersion, "(untracked dev build)"; got != want {
- t.Errorf("Expected appVersion='%s', got: '%s'", want, got)
- }
-
- gitTag = "v1.1"
- setVersion()
- if devBuild {
- t.Error("Expected a stable build if gitTag is set with no changes")
- }
- if got, want := appVersion, "1.1"; got != want {
- t.Errorf("Expected appVersion='%s', got: '%s'", want, got)
- }
-
- gitTag = ""
- gitNearestTag = "v1.0"
- gitCommit = "deadbeef"
- buildDate = "Fri Feb 26 06:53:17 UTC 2016"
- setVersion()
- if !devBuild {
- t.Error("Expected inferring a dev build when gitTag is empty")
- }
- if got, want := appVersion, "1.0 (+deadbeef Fri Feb 26 06:53:17 UTC 2016)"; got != want {
- t.Errorf("Expected appVersion='%s', got: '%s'", want, got)
- }
-}