Skip to content

Commit 40070cc

Browse files
committed
rename the task/service/test package to task/service/taskservicetest
This has a few follow-on effects. Namely one no longer needs to have a special name for the task/service/test package (previously this was custom named to "taskServiceTest"). Now it just follows naturally as "taskservicetest" with no custom naming required. This change brings the name inline with current Go best practices for package names and package naming, and also makes it easier for LSP-enabled editors to automatically manage Go imports. In addition, it follows patterns found in the Go stdlib (see httptest, slogtest, fstest, iotest, etc.) In general I would have preferred to keep the name to the concatenation of only two package names, but "service" is a very common package within platform, so I think it makes sense to keep all three parts, as otherwise there would be four "servicetest" packages[^2] and we'd be back to custom renaming the imports which just makes things harder all around. [^1]: https://go.dev/doc/effective_go#package-names [^2]: `$ go list ./... | rg '/(task)?service/?test'`
1 parent 02a0627 commit 40070cc

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

task/service/api/api_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import (
1111
logTest "github.com/tidepool-org/platform/log/test"
1212
taskService "github.com/tidepool-org/platform/task/service"
1313
taskServiceApi "github.com/tidepool-org/platform/task/service/api"
14-
taskServiceTest "github.com/tidepool-org/platform/task/service/test"
14+
"github.com/tidepool-org/platform/task/service/taskservicetest"
1515
testRest "github.com/tidepool-org/platform/test/rest"
1616
)
1717

1818
var _ = Describe("API", func() {
19-
var service *taskServiceTest.Service
19+
var service *taskservicetest.Service
2020

2121
BeforeEach(func() {
22-
service = taskServiceTest.NewService()
22+
service = taskservicetest.NewService()
2323
})
2424

2525
Context("NewRouter", func() {
@@ -60,7 +60,7 @@ var _ = Describe("API", func() {
6060
response = testRest.NewResponseWriter()
6161
request = testRest.NewRequest()
6262
request.Request = request.WithContext(log.NewContextWithLogger(request.Context(), logTest.NewLogger()))
63-
service = taskServiceTest.NewService()
63+
service = taskservicetest.NewService()
6464
var err error
6565
router, err = taskServiceApi.NewRouter(service)
6666
Expect(err).ToNot(HaveOccurred())

task/service/api/v1/v1_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import (
88
. "github.com/onsi/gomega/gstruct"
99

1010
taskServiceApiV1 "github.com/tidepool-org/platform/task/service/api/v1"
11-
taskServiceTest "github.com/tidepool-org/platform/task/service/test"
11+
"github.com/tidepool-org/platform/task/service/taskservicetest"
1212
)
1313

1414
var _ = Describe("V1", func() {
15-
var service *taskServiceTest.Service
15+
var service *taskservicetest.Service
1616

1717
BeforeEach(func() {
18-
service = taskServiceTest.NewService()
18+
service = taskservicetest.NewService()
1919
})
2020

2121
Context("NewRouter", func() {

task/service/test/service.go renamed to task/service/taskservicetest/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package test
1+
package taskservicetest
22

33
import (
44
"context"

0 commit comments

Comments
 (0)