1package git23import (4 "context"5 "fmt"6 "testing"78 "github.com/stretchr/testify/assert"9)1011func TestRepository_Blame(t *testing.T) {12 ctx := context.Background()1314 t.Run("bad file", func(t *testing.T) {15 _, err := testrepo.Blame(ctx, "", "404.txt")16 assert.Error(t, err)17 })1819 blame, err := testrepo.Blame(ctx, testrepoMarks[32].String(), "README.txt")20 assert.Nil(t, err)2122 // Assert representative commits23 // https://github.com/gogs/git-module-testrepo/blame/master/README.txt24 tests := []struct {25 line int26 expID string27 }{28 {line: 1, expID: testrepoMarks[1].String()},29 {line: 3, expID: testrepoMarks[20].String()},30 {line: 5, expID: testrepoMarks[1].String()},31 {line: 13, expID: testrepoMarks[13].String()},32 }33 for _, test := range tests {34 t.Run(fmt.Sprintf("Line %d", test.line), func(t *testing.T) {35 line := blame.Line(test.line)36 assert.Equal(t, test.expID, line.ID.String())37 })38 }39}