File: model_test.go

package info (click to toggle)
golang-github-golang-mock 1.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, forky, sid, trixie
  • size: 800 kB
  • sloc: sh: 58; makefile: 3
file content (36 lines) | stat: -rw-r--r-- 800 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package model

import (
	"fmt"
	"testing"
)

func TestImpPath(t *testing.T) {
	nonVendor := "github.com/foo/bar"
	if nonVendor != impPath(nonVendor) {
		t.Errorf("")

	}
	testCases := []struct {
		input string
		want  string
	}{
		{"foo/bar", "foo/bar"},
		{"vendor/foo/bar", "foo/bar"},
		{"vendor/foo/vendor/bar", "bar"},
		{"/vendor/foo/bar", "foo/bar"},
		{"qux/vendor/foo/bar", "foo/bar"},
		{"qux/vendor/foo/vendor/bar", "bar"},
		{"govendor/foo", "govendor/foo"},
		{"foo/govendor/bar", "foo/govendor/bar"},
		{"vendors/foo", "vendors/foo"},
		{"foo/vendors/bar", "foo/vendors/bar"},
	}
	for _, tc := range testCases {
		t.Run(fmt.Sprintf("input %s", tc.input), func(t *testing.T) {
			if got := impPath(tc.input); got != tc.want {
				t.Errorf("got %s; want %s", got, tc.want)
			}
		})
	}
}