github.com/mattbailey/reviewdog@v0.10.0/service/github/githubutils/utils_test.go (about)

     1  package githubutils
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/reviewdog/reviewdog"
     7  )
     8  
     9  func TestLinkedMarkdownCheckResult(t *testing.T) {
    10  	tests := []struct {
    11  		owner, repo, sha string
    12  		c                *reviewdog.CheckResult
    13  		want             string
    14  	}{
    15  		{
    16  			owner: "o",
    17  			repo:  "r",
    18  			sha:   "s",
    19  			c: &reviewdog.CheckResult{
    20  				Path:    "path/to/file.txt",
    21  				Lnum:    1414,
    22  				Col:     14,
    23  				Message: "msg",
    24  			},
    25  			want: "[path/to/file.txt|1414 col 14|](http://github.com/o/r/blob/s/path/to/file.txt#L1414) msg",
    26  		},
    27  		{
    28  			owner: "o",
    29  			repo:  "r",
    30  			sha:   "s",
    31  			c: &reviewdog.CheckResult{
    32  				Path:    "path/to/file.txt",
    33  				Lnum:    1414,
    34  				Col:     0,
    35  				Message: "msg",
    36  			},
    37  			want: "[path/to/file.txt|1414|](http://github.com/o/r/blob/s/path/to/file.txt#L1414) msg",
    38  		},
    39  		{
    40  			owner: "o",
    41  			repo:  "r",
    42  			sha:   "s",
    43  			c: &reviewdog.CheckResult{
    44  				Path:    "path/to/file.txt",
    45  				Lnum:    0,
    46  				Col:     0,
    47  				Message: "msg",
    48  			},
    49  			want: "[path/to/file.txt||](http://github.com/o/r/blob/s/path/to/file.txt) msg",
    50  		},
    51  	}
    52  	for _, tt := range tests {
    53  		if got := LinkedMarkdownCheckResult(tt.owner, tt.repo, tt.sha, tt.c); got != tt.want {
    54  			t.Errorf("LinkedMarkdownCheckResult(%q, %q, %q, %#v) = %q, want %q",
    55  				tt.owner, tt.repo, tt.sha, tt.c, got, tt.want)
    56  		}
    57  	}
    58  }