github.com/skf/moby@v1.13.1/opts/quotedstring_test.go (about)

     1  package opts
     2  
     3  import (
     4  	"github.com/docker/docker/pkg/testutil/assert"
     5  	"testing"
     6  )
     7  
     8  func TestQuotedStringSetWithQuotes(t *testing.T) {
     9  	value := ""
    10  	qs := NewQuotedString(&value)
    11  	assert.NilError(t, qs.Set("\"something\""))
    12  	assert.Equal(t, qs.String(), "something")
    13  	assert.Equal(t, value, "something")
    14  }
    15  
    16  func TestQuotedStringSetWithMismatchedQuotes(t *testing.T) {
    17  	value := ""
    18  	qs := NewQuotedString(&value)
    19  	assert.NilError(t, qs.Set("\"something'"))
    20  	assert.Equal(t, qs.String(), "\"something'")
    21  }
    22  
    23  func TestQuotedStringSetWithNoQuotes(t *testing.T) {
    24  	value := ""
    25  	qs := NewQuotedString(&value)
    26  	assert.NilError(t, qs.Set("something"))
    27  	assert.Equal(t, qs.String(), "something")
    28  }