github.com/friedemannf/reviewdog@v0.14.0/project/conf_test.go (about)

     1  package project
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/kylelemons/godebug/pretty"
     7  )
     8  
     9  func TestParse(t *testing.T) {
    10  	const yml = `
    11  # reviewdog.yml
    12  
    13  runner:
    14    golint:
    15      cmd: golint ./...
    16      level: info
    17      errorformat:
    18        - "%f:%l:%c: %m"
    19    govet:
    20      cmd: go tool vet -all -shadowstrict .
    21      format: govet
    22      level: warning
    23    namekey:
    24      cmd: echo 'name'
    25      name: nameoverwritten
    26      format: checkstyle
    27      level: error
    28  `
    29  
    30  	want := &Config{
    31  		Runner: map[string]*Runner{
    32  			"golint": {
    33  				Cmd:         "golint ./...",
    34  				Errorformat: []string{`%f:%l:%c: %m`},
    35  				Name:        "golint",
    36  				Level:       "info",
    37  			},
    38  			"govet": {
    39  				Cmd:    "go tool vet -all -shadowstrict .",
    40  				Format: "govet",
    41  				Name:   "govet",
    42  				Level:  "warning",
    43  			},
    44  			"namekey": {
    45  				Cmd:    "echo 'name'",
    46  				Format: "checkstyle",
    47  				Name:   "nameoverwritten",
    48  				Level:  "error",
    49  			},
    50  		},
    51  	}
    52  
    53  	got, err := Parse([]byte(yml))
    54  	if err != nil {
    55  		t.Fatal(err)
    56  	}
    57  	if diff := pretty.Compare(got, want); diff != "" {
    58  		t.Errorf("Parse() diff: (-got +want)\n%s", diff)
    59  	}
    60  
    61  }