github.com/daixiang0/gci@v0.13.0/pkg/config/config_test.go (about)

     1  package config
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	"github.com/daixiang0/gci/pkg/section"
     9  )
    10  
    11  // the custom sections sort alphabetically as default.
    12  func TestParseOrder(t *testing.T) {
    13  	cfg := YamlConfig{
    14  		SectionStrings: []string{"default", "prefix(github/daixiang0/gci)", "prefix(github/daixiang0/gai)"},
    15  	}
    16  	gciCfg, err := cfg.Parse()
    17  	assert.NoError(t, err)
    18  	assert.Equal(t, section.SectionList{section.Default{}, section.Custom{Prefix: "github/daixiang0/gai"}, section.Custom{Prefix: "github/daixiang0/gci"}}, gciCfg.Sections)
    19  }
    20  
    21  func TestParseCustomOrder(t *testing.T) {
    22  	cfg := YamlConfig{
    23  		SectionStrings: []string{"default", "prefix(github/daixiang0/gci)", "prefix(github/daixiang0/gai)"},
    24  		Cfg: BoolConfig{
    25  			CustomOrder: true,
    26  		},
    27  	}
    28  	gciCfg, err := cfg.Parse()
    29  	assert.NoError(t, err)
    30  	assert.Equal(t, section.SectionList{section.Default{}, section.Custom{Prefix: "github/daixiang0/gci"}, section.Custom{Prefix: "github/daixiang0/gai"}}, gciCfg.Sections)
    31  }