...

Source file src/github.com/mailru/easyjson/parser/pkgpath_test.go

Documentation: github.com/mailru/easyjson/parser

     1  package parser
     2  
     3  import "testing"
     4  
     5  func Test_getModulePath(t *testing.T) {
     6  	tests := map[string]struct {
     7  		goModPath string
     8  		want      string
     9  	}{
    10  		"valid go.mod without comments and deps": {
    11  			goModPath: "./testdata/default.go.mod",
    12  			want:      "example.com/user/project",
    13  		},
    14  		"valid go.mod with comments and without deps": {
    15  			goModPath: "./testdata/comments.go.mod",
    16  			want:      "example.com/user/project",
    17  		},
    18  		"valid go.mod with comments and deps": {
    19  			goModPath: "./testdata/comments_deps.go.mod",
    20  			want:      "example.com/user/project",
    21  		},
    22  		"actual easyjson go.mod": {
    23  			goModPath: "../go.mod",
    24  			want:      "github.com/mailru/easyjson",
    25  		},
    26  		"invalid go.mod with missing module": {
    27  			goModPath: "./testdata/missing_module.go",
    28  			want:      "",
    29  		},
    30  	}
    31  	for name := range tests {
    32  		tt := tests[name]
    33  		t.Run(name, func(t *testing.T) {
    34  			if got := getModulePath(tt.goModPath); got != tt.want {
    35  				t.Errorf("getModulePath() = %v, want %v", got, tt.want)
    36  			}
    37  		})
    38  	}
    39  }
    40  

View as plain text