Skip to content

Commit 384bf9f

Browse files
committed
testserver: suffix structs with Server
1 parent e4109ee commit 384bf9f

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

controllers/helmchart_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var _ = Describe("HelmChartReconciler", func() {
4646
Context("HelmChart", func() {
4747
var (
4848
namespace *corev1.Namespace
49-
helmServer *testserver.Helm
49+
helmServer *testserver.HelmServer
5050
err error
5151
)
5252

controllers/helmrepository_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var _ = Describe("HelmRepositoryReconciler", func() {
4545
Context("HelmRepository", func() {
4646
var (
4747
namespace *corev1.Namespace
48-
helmServer *testserver.Helm
48+
helmServer *testserver.HelmServer
4949
err error
5050
)
5151

internal/testserver/helm.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,39 @@ import (
2525
"sigs.k8s.io/yaml"
2626
)
2727

28-
func NewTempHelmServer() (*Helm, error) {
28+
func NewTempHelmServer() (*HelmServer, error) {
2929
server, err := NewTempHTTPServer()
3030
if err != nil {
3131
return nil, err
3232
}
33-
helm := &Helm{server}
33+
helm := &HelmServer{server}
3434
return helm, nil
3535
}
3636

37-
type Helm struct {
38-
*HTTP
37+
type HelmServer struct {
38+
*HTTPServer
3939
}
4040

41-
func (s *Helm) GenerateIndex() error {
42-
index, err := repo.IndexDirectory(s.HTTP.docroot, s.HTTP.URL())
41+
func (s *HelmServer) GenerateIndex() error {
42+
index, err := repo.IndexDirectory(s.HTTPServer.docroot, s.HTTPServer.URL())
4343
if err != nil {
4444
return err
4545
}
4646
d, err := yaml.Marshal(index)
4747
if err != nil {
4848
return err
4949
}
50-
f := filepath.Join(s.HTTP.docroot, "index.yaml")
50+
f := filepath.Join(s.HTTPServer.docroot, "index.yaml")
5151
return ioutil.WriteFile(f, d, 0644)
5252
}
5353

54-
func (s *Helm) PackageChart(path string) error {
54+
func (s *HelmServer) PackageChart(path string) error {
5555
return s.PackageChartWithVersion(path, "")
5656
}
5757

58-
func (s *Helm) PackageChartWithVersion(path, version string) error {
58+
func (s *HelmServer) PackageChartWithVersion(path, version string) error {
5959
pkg := action.NewPackage()
60-
pkg.Destination = s.HTTP.docroot
60+
pkg.Destination = s.HTTPServer.docroot
6161
pkg.Version = version
6262
_, err := pkg.Run(path, nil)
6363
return err

internal/testserver/http.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"path/filepath"
2626
)
2727

28-
func NewTempHTTPServer() (*HTTP, error) {
28+
func NewTempHTTPServer() (*HTTPServer, error) {
2929
tmpDir, err := ioutil.TempDir("", "http-test-")
3030
if err != nil {
3131
return nil, err
@@ -34,28 +34,28 @@ func NewTempHTTPServer() (*HTTP, error) {
3434
return srv, nil
3535
}
3636

37-
func NewHTTPServer(docroot string) *HTTP {
37+
func NewHTTPServer(docroot string) *HTTPServer {
3838
root, err := filepath.Abs(docroot)
3939
if err != nil {
4040
panic(err)
4141
}
42-
return &HTTP{
42+
return &HTTPServer{
4343
docroot: root,
4444
}
4545
}
4646

47-
type HTTP struct {
47+
type HTTPServer struct {
4848
docroot string
4949
middleware func(http.Handler) http.Handler
5050
server *httptest.Server
5151
}
5252

53-
func (s *HTTP) WithMiddleware(m func(handler http.Handler) http.Handler) *HTTP {
53+
func (s *HTTPServer) WithMiddleware(m func(handler http.Handler) http.Handler) *HTTPServer {
5454
s.middleware = m
5555
return s
5656
}
5757

58-
func (s *HTTP) Start() {
58+
func (s *HTTPServer) Start() {
5959
s.server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
6060
handler := http.FileServer(http.Dir(s.docroot))
6161
if s.middleware != nil {
@@ -66,7 +66,7 @@ func (s *HTTP) Start() {
6666
}))
6767
}
6868

69-
func (s *HTTP) StartTLS(cert, key, ca []byte) error {
69+
func (s *HTTPServer) StartTLS(cert, key, ca []byte) error {
7070
s.server = httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
7171
handler := http.FileServer(http.Dir(s.docroot))
7272
if s.middleware != nil {
@@ -95,17 +95,17 @@ func (s *HTTP) StartTLS(cert, key, ca []byte) error {
9595
return nil
9696
}
9797

98-
func (s *HTTP) Stop() {
98+
func (s *HTTPServer) Stop() {
9999
if s.server != nil {
100100
s.server.Close()
101101
}
102102
}
103103

104-
func (s *HTTP) Root() string {
104+
func (s *HTTPServer) Root() string {
105105
return s.docroot
106106
}
107107

108-
func (s *HTTP) URL() string {
108+
func (s *HTTPServer) URL() string {
109109
if s.server != nil {
110110
return s.server.URL
111111
}

0 commit comments

Comments
 (0)