github.com/mistwind/reviewdog@v0.0.0-20230322024206-9cfa11856d58/service/github/githubutils/utils_test.go (about) 1 package githubutils 2 3 import ( 4 "testing" 5 6 "github.com/mistwind/reviewdog/proto/rdf" 7 ) 8 9 func TestLinkedMarkdownDiagnostic(t *testing.T) { 10 tests := []struct { 11 owner, repo, sha string 12 d *rdf.Diagnostic 13 want string 14 }{ 15 { 16 owner: "o", 17 repo: "r", 18 sha: "s", 19 d: &rdf.Diagnostic{ 20 Location: &rdf.Location{ 21 Path: "path/to/file.txt", 22 Range: &rdf.Range{Start: &rdf.Position{ 23 Line: 1414, 24 Column: 14, 25 }}, 26 }, 27 Message: "msg", 28 }, 29 want: "[path/to/file.txt|1414 col 14|](http://github.com/o/r/blob/s/path/to/file.txt#L1414) msg", 30 }, 31 { 32 owner: "o", 33 repo: "r", 34 sha: "s", 35 d: &rdf.Diagnostic{ 36 Location: &rdf.Location{ 37 Path: "path/to/file.txt", 38 Range: &rdf.Range{Start: &rdf.Position{ 39 Line: 1414, 40 Column: 0, 41 }}, 42 }, 43 Message: "msg", 44 }, 45 want: "[path/to/file.txt|1414|](http://github.com/o/r/blob/s/path/to/file.txt#L1414) msg", 46 }, 47 { 48 owner: "o", 49 repo: "r", 50 sha: "s", 51 d: &rdf.Diagnostic{ 52 Location: &rdf.Location{ 53 Path: "path/to/file.txt", 54 }, 55 Message: "msg", 56 }, 57 want: "[path/to/file.txt||](http://github.com/o/r/blob/s/path/to/file.txt) msg", 58 }, 59 } 60 for _, tt := range tests { 61 if got := LinkedMarkdownDiagnostic(tt.owner, tt.repo, tt.sha, tt.d); got != tt.want { 62 t.Errorf("LinkedMarkdownDiagnostic(%q, %q, %q, %#v) = %q, want %q", 63 tt.owner, tt.repo, tt.sha, tt.d, got, tt.want) 64 } 65 } 66 }