diff --git a/Makefile b/Makefile index 4a4510b..c33ba3e 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ lint: deps @-echo "NOTE: some linters (gotype) require a recent 'go install'" go get -u github.com/alecthomas/gometalinter gometalinter --install --update - gometalinter --deadline=300s --disable=dupl --concurrency=2 ./... + gometalinter --deadline=300s --disable=dupl --concurrency=4 goconvey: @-killall goconvey diff --git a/cassette.go b/cassette.go index 6ed91e3..519ab08 100644 --- a/cassette.go +++ b/cassette.go @@ -224,10 +224,12 @@ type cassette struct { removeTLS bool } -func NewCassette(name string, path string) *cassette { +// newCassette creates a ready to use new cassette. +func newCassette(name string, path string) *cassette { return &cassette{Name: name, Path: path, trackSliceMutex: &sync.RWMutex{}} } +// isLongPlay returns true if the cassette content is compressed. func (k7 *cassette) isLongPlay() bool { return strings.HasSuffix(k7.Name, ".gz") } @@ -428,7 +430,7 @@ func loadCassette(cassetteName, cassettePath string) (*cassette, error) { // provide an empty cassette as a minimum if k7 == nil { - k7 = NewCassette(cassetteName, cassettePath) + k7 = newCassette(cassetteName, cassettePath) } // initial stats @@ -441,7 +443,7 @@ func loadCassette(cassetteName, cassettePath string) (*cassette, error) { func readCassetteFromFile(cassetteName, cassettePath string) (*cassette, error) { filename := cassetteNameToFilename(cassetteName, cassettePath) - k7 := NewCassette(cassetteName, cassettePath) + k7 := newCassette(cassetteName, cassettePath) data, err := ioutil.ReadFile(filename) if os.IsNotExist(err) { diff --git a/cassette_test.go b/cassette_test.go index c35dead..0fbd564 100644 --- a/cassette_test.go +++ b/cassette_test.go @@ -65,7 +65,7 @@ func Test_cassette_gzipFilter(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - k7 := NewCassette(tt.fields.Name, tt.fields.Path) + k7 := newCassette(tt.fields.Name, tt.fields.Path) k7.Tracks = tt.fields.Tracks k7.tracksLoaded = tt.fields.stats.TracksLoaded @@ -110,7 +110,7 @@ func Test_cassette_isLongPlay(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - k7 := NewCassette(tt.fields.Name, tt.fields.Path) + k7 := newCassette(tt.fields.Name, tt.fields.Path) k7.Tracks = tt.fields.Tracks k7.tracksLoaded = tt.fields.stats.TracksLoaded @@ -163,7 +163,7 @@ func Test_cassette_gunzipFilter(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - k7 := NewCassette(tt.fields.Name, tt.fields.Path) + k7 := newCassette(tt.fields.Name, tt.fields.Path) k7.Tracks = tt.fields.Tracks k7.tracksLoaded = tt.fields.stats.TracksLoaded @@ -280,7 +280,7 @@ func Test_cassette_addTrack(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - k7 := NewCassette(tt.name, tt.name) + k7 := newCassette(tt.name, tt.name) k7.removeTLS = tt.fields.removeTLS k7.addTrack(&tt.args.track) diff --git a/vcr_transport_test.go b/vcr_transport_test.go index 6258ed8..e4851ad 100644 --- a/vcr_transport_test.go +++ b/vcr_transport_test.go @@ -52,7 +52,7 @@ func Test_vcrTransport_RoundTrip_doesNotChangeLiveReqOrLiveResp(t *testing.T) { Logger: logger, CassettePath: "", }, - Cassette: NewCassette("", ""), + Cassette: newCassette("", ""), } req, err := http.NewRequest("GET", "https://example.com/path?query", toReadCloser([]byte("Lorem ipsum dolor sit amet")))