github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/opts/quotedstring_test.go (about)

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