github.com/blend/go-sdk@v1.20220411.3/profanity/option_test.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package profanity
     9  
    10  import (
    11  	"testing"
    12  
    13  	"github.com/blend/go-sdk/assert"
    14  )
    15  
    16  func TestConfigOptions(t *testing.T) {
    17  	assert := assert.New(t)
    18  
    19  	p := &Profanity{}
    20  
    21  	assert.False(p.Config.VerboseOrDefault())
    22  	OptVerbose(true)(p)
    23  	assert.True(p.Config.VerboseOrDefault())
    24  
    25  	assert.False(p.Config.DebugOrDefault())
    26  	OptDebug(true)(p)
    27  	assert.True(p.Config.DebugOrDefault())
    28  
    29  	assert.False(p.Config.ExitFirstOrDefault())
    30  	OptExitFirst(true)(p)
    31  	assert.True(p.Config.ExitFirstOrDefault())
    32  
    33  	assert.Empty(p.Config.Root)
    34  	OptRoot("../foo")(p)
    35  	assert.Equal("../foo", p.Config.Root)
    36  
    37  	assert.Equal(DefaultRulesFile, p.Config.RulesFileOrDefault())
    38  	OptRulesFile("my_rules.yml")(p)
    39  
    40  	assert.Empty(p.Config.Files.Include)
    41  	OptIncludeFiles("foo", "bar", "baz")(p)
    42  	assert.Equal([]string{"foo", "bar", "baz"}, p.Config.Files.Include)
    43  
    44  	assert.Empty(p.Config.Files.Exclude)
    45  	OptExcludeFiles("foo", "bar", "baz")(p)
    46  	assert.Equal([]string{"foo", "bar", "baz"}, p.Config.Files.Exclude)
    47  }