mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-30 19:55:04 -04:00
caddyfile: Move NewTestDispenser into non-test file (#3439)
This commit is contained in:
parent
22055c5e0f
commit
ffc125d6f5
@ -17,6 +17,8 @@ package caddyfile
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
"strings"
|
"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
|
// Next loads the next token. Returns true if a token
|
||||||
// was loaded; false otherwise. If false, all tokens
|
// was loaded; false otherwise. If false, all tokens
|
||||||
// have been consumed.
|
// have been consumed.
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
package caddyfile
|
package caddyfile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"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)
|
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)
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user