github.com/blend/go-sdk@v1.20220411.3/copyright/config_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 copyright
     9  
    10  import (
    11  	"testing"
    12  	"time"
    13  
    14  	"github.com/blend/go-sdk/assert"
    15  	"github.com/blend/go-sdk/ref"
    16  )
    17  
    18  func Test_Config(t *testing.T) {
    19  	t.Parallel()
    20  	its := assert.New(t)
    21  
    22  	var cfg Config
    23  
    24  	its.Equal(DefaultNoticeBodyTemplate, cfg.NoticeBodyTemplateOrDefault())
    25  	cfg.NoticeBodyTemplate = "not-" + DefaultNoticeBodyTemplate
    26  	its.Equal("not-"+DefaultNoticeBodyTemplate, cfg.NoticeBodyTemplateOrDefault())
    27  
    28  	its.Equal(time.Now().UTC().Year(), cfg.YearOrDefault())
    29  	cfg.Year = time.Now().UTC().Year() - 10
    30  	its.Equal(time.Now().UTC().Year()-10, cfg.YearOrDefault())
    31  
    32  	its.Equal(DefaultCompany, cfg.CompanyOrDefault())
    33  	cfg.Company = "not-" + DefaultCompany
    34  	its.Equal("not-"+DefaultCompany, cfg.CompanyOrDefault())
    35  
    36  	its.Equal(DefaultOpenSourceLicense, cfg.LicenseOrDefault())
    37  	cfg.License = "not-" + DefaultOpenSourceLicense
    38  	its.Equal("not-"+DefaultOpenSourceLicense, cfg.LicenseOrDefault())
    39  
    40  	its.Equal(DefaultRestrictionsInternal, cfg.RestrictionsOrDefault())
    41  	cfg.Restrictions = "not-" + DefaultRestrictionsInternal
    42  	its.Equal("not-"+DefaultRestrictionsInternal, cfg.RestrictionsOrDefault())
    43  
    44  	its.Equal(DefaultExtensionNoticeTemplates, cfg.ExtensionNoticeTemplatesOrDefault())
    45  	cfg.ExtensionNoticeTemplates = map[string]string{"foo": "bar"}
    46  	its.Equal("bar", cfg.ExtensionNoticeTemplatesOrDefault()["foo"])
    47  
    48  	its.False(cfg.ExitFirstOrDefault())
    49  	cfg.ExitFirst = ref.Bool(true)
    50  	its.True(cfg.ExitFirstOrDefault())
    51  
    52  	its.False(cfg.QuietOrDefault())
    53  	cfg.Quiet = ref.Bool(true)
    54  	its.True(cfg.QuietOrDefault())
    55  
    56  	its.False(cfg.VerboseOrDefault())
    57  	cfg.Verbose = ref.Bool(true)
    58  	its.True(cfg.VerboseOrDefault())
    59  
    60  	its.False(cfg.DebugOrDefault())
    61  	cfg.Debug = ref.Bool(true)
    62  	its.True(cfg.DebugOrDefault())
    63  
    64  	its.True(cfg.ShowDiffOrDefault())
    65  	cfg.ShowDiff = ref.Bool(false)
    66  	its.False(cfg.ShowDiffOrDefault())
    67  }