summaryrefslogtreecommitdiff
path: root/caddyconfig
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2020-05-26 15:45:22 -0400
committerGitHub <noreply@github.com>2020-05-26 13:45:22 -0600
commitffc125d6f5606ab4370ea244e66dfb05cd78eb28 (patch)
tree80e25fd168ee36e5941188176c57462c2b3622c7 /caddyconfig
parent22055c5e0f07cf8865c148b8139d221123988aad (diff)
caddyfile: Move NewTestDispenser into non-test file (#3439)
Diffstat (limited to 'caddyconfig')
-rwxr-xr-xcaddyconfig/caddyfile/dispenser.go12
-rwxr-xr-xcaddyconfig/caddyfile/dispenser_test.go12
2 files changed, 12 insertions, 12 deletions
diff --git a/caddyconfig/caddyfile/dispenser.go b/caddyconfig/caddyfile/dispenser.go
index 932ab61..22cd3dc 100755
--- a/caddyconfig/caddyfile/dispenser.go
+++ b/caddyconfig/caddyfile/dispenser.go
@@ -17,6 +17,8 @@ package caddyfile
import (
"errors"
"fmt"
+ "io"
+ "log"
"strings"
)
@@ -37,6 +39,16 @@ func NewDispenser(tokens []Token) *Dispenser {
}
}
+// NewTestDispenser parses input into tokens and creates a new
+// Disenser for test purposes only; any errors are fatal.
+func NewTestDispenser(input string) *Dispenser {
+ tokens, err := allTokens("Testfile", []byte(input))
+ if err != nil && err != io.EOF {
+ log.Fatalf("getting all tokens from input: %v", err)
+ }
+ return NewDispenser(tokens)
+}
+
// Next loads the next token. Returns true if a token
// was loaded; false otherwise. If false, all tokens
// have been consumed.
diff --git a/caddyconfig/caddyfile/dispenser_test.go b/caddyconfig/caddyfile/dispenser_test.go
index 4970f9d..577872f 100755
--- a/caddyconfig/caddyfile/dispenser_test.go
+++ b/caddyconfig/caddyfile/dispenser_test.go
@@ -15,8 +15,6 @@
package caddyfile
import (
- "io"
- "log"
"reflect"
"strings"
"testing"
@@ -306,13 +304,3 @@ func TestDispenser_ArgErr_Err(t *testing.T) {
t.Errorf("Expected error message with custom message in it ('foobar'); got '%v'", err)
}
}
-
-// NewTestDispenser parses input into tokens and creates a new
-// Disenser for test purposes only; any errors are fatal.
-func NewTestDispenser(input string) *Dispenser {
- tokens, err := allTokens("Testfile", []byte(input))
- if err != nil && err != io.EOF {
- log.Fatalf("getting all tokens from input: %v", err)
- }
- return NewDispenser(tokens)
-}