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