github.com/databricks/cli@v0.203.0/libs/flags/output_test.go (about)

     1  package flags
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestOutputFlag(t *testing.T) {
    10  	var f Output
    11  	var err error
    12  
    13  	// Invalid
    14  	err = f.Set("foo")
    15  	assert.EqualError(t, err, "accepted arguments are json and text")
    16  
    17  	// Lowercase
    18  	err = f.Set("text")
    19  	assert.NoError(t, err)
    20  	assert.Equal(t, "text", f.String())
    21  
    22  	// Uppercase
    23  	err = f.Set("TEXT")
    24  	assert.NoError(t, err)
    25  	assert.Equal(t, "text", f.String())
    26  
    27  	// Lowercase
    28  	err = f.Set("json")
    29  	assert.NoError(t, err)
    30  	assert.Equal(t, "json", f.String())
    31  
    32  	// Uppercase
    33  	err = f.Set("JSON")
    34  	assert.NoError(t, err)
    35  	assert.Equal(t, "json", f.String())
    36  }