github.com/jiasir/docker@v1.3.3-0.20170609024000-252e610103e7/opts/quotedstring_test.go (about)

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