2016-12-29 17:28:28 -05:00
|
|
|
package opts
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/docker/pkg/testutil/assert"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestQuotedStringSetWithQuotes(t *testing.T) {
|
2017-01-03 15:58:41 -05:00
|
|
|
value := ""
|
|
|
|
qs := NewQuotedString(&value)
|
2016-12-29 17:28:28 -05:00
|
|
|
assert.NilError(t, qs.Set("\"something\""))
|
|
|
|
assert.Equal(t, qs.String(), "something")
|
2017-01-03 15:58:41 -05:00
|
|
|
assert.Equal(t, value, "something")
|
2016-12-29 17:28:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestQuotedStringSetWithMismatchedQuotes(t *testing.T) {
|
2017-01-03 15:58:41 -05:00
|
|
|
value := ""
|
|
|
|
qs := NewQuotedString(&value)
|
2016-12-29 17:28:28 -05:00
|
|
|
assert.NilError(t, qs.Set("\"something'"))
|
|
|
|
assert.Equal(t, qs.String(), "\"something'")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestQuotedStringSetWithNoQuotes(t *testing.T) {
|
2017-01-03 15:58:41 -05:00
|
|
|
value := ""
|
|
|
|
qs := NewQuotedString(&value)
|
2016-12-29 17:28:28 -05:00
|
|
|
assert.NilError(t, qs.Set("something"))
|
|
|
|
assert.Equal(t, qs.String(), "something")
|
|
|
|
}
|