Skip to content
This repository has been archived by the owner on Jul 4, 2021. It is now read-only.

Commit

Permalink
style: rename Url to URL
Browse files Browse the repository at this point in the history
  • Loading branch information
agravelot committed May 5, 2021
1 parent 839f551 commit 7b11924
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cache/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestNew(t *testing.T) {
args: args{
config.Config{
Processor: "imaginary",
Imaginary: config.ImaginaryProcessorConfig{Url: "http://localhost"},
Imaginary: config.ImaginaryProcessorConfig{URL: "http://localhost"},
Cache: "unsupported",
},
},
Expand Down
8 changes: 6 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// Package config provide configurations structs for imageopti middleware.
package config

// ImaginaryProcessorConfig define imaginary image processor configurations.
type ImaginaryProcessorConfig struct {
Url string `json:"url" yaml:"url" toml:"url"`
URL string `json:"url" yaml:"url" toml:"url"`
}

// RedisCacheConfig define redis cache system configurations.
type RedisCacheConfig struct {
Url string `json:"url" yaml:"url" toml:"url"`
URL string `json:"url" yaml:"url" toml:"url"`
}

// FileCacheConfig define file cache system configurations.
type FileCacheConfig struct {
Path string `json:"path" yaml:"path" toml:"path"`
}
Expand Down
4 changes: 2 additions & 2 deletions image_optimizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func CreateConfig() *Config {
config.Config{
Processor: "",
Cache: "",
Imaginary: config.ImaginaryProcessorConfig{Url: ""},
Redis: config.RedisCacheConfig{Url: ""},
Imaginary: config.ImaginaryProcessorConfig{URL: ""},
Redis: config.RedisCacheConfig{URL: ""},
File: config.FileCacheConfig{Path: ""},
},
}
Expand Down
16 changes: 8 additions & 8 deletions image_optimizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ func TestImageOptimizer_ServeHTTP(t *testing.T) {
args: args{
config: config.Config{
Processor: "imaginary",
Imaginary: config.ImaginaryProcessorConfig{Url: "http://localhost"},
Imaginary: config.ImaginaryProcessorConfig{URL: "http://localhost"},
Cache: "none",
Redis: config.RedisCacheConfig{Url: ""},
Redis: config.RedisCacheConfig{URL: ""},
File: config.FileCacheConfig{Path: ""},
},
},
Expand All @@ -51,9 +51,9 @@ func TestImageOptimizer_ServeHTTP(t *testing.T) {
config: config.Config{
Processor: "",
Cache: "",
Redis: config.RedisCacheConfig{Url: ""},
Redis: config.RedisCacheConfig{URL: ""},
File: config.FileCacheConfig{Path: ""},
Imaginary: config.ImaginaryProcessorConfig{Url: ""},
Imaginary: config.ImaginaryProcessorConfig{URL: ""},
},
},
want: false,
Expand Down Expand Up @@ -82,9 +82,9 @@ func TestImageOptimizer_ServeHTTP(t *testing.T) {
config: config.Config{
Processor: "local",
Cache: "memory",
Redis: config.RedisCacheConfig{Url: ""},
Redis: config.RedisCacheConfig{URL: ""},
File: config.FileCacheConfig{Path: ""},
Imaginary: config.ImaginaryProcessorConfig{Url: ""},
Imaginary: config.ImaginaryProcessorConfig{URL: ""},
},
},
want: false,
Expand All @@ -101,9 +101,9 @@ func TestImageOptimizer_ServeHTTP(t *testing.T) {
config: config.Config{
Processor: "none",
Cache: "",
Redis: config.RedisCacheConfig{Url: ""},
Redis: config.RedisCacheConfig{URL: ""},
File: config.FileCacheConfig{Path: ""},
Imaginary: config.ImaginaryProcessorConfig{Url: ""},
Imaginary: config.ImaginaryProcessorConfig{URL: ""},
},
},
want: false,
Expand Down
8 changes: 4 additions & 4 deletions processor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ func TestNew(t *testing.T) {
args: args{
config.Config{
Processor: "imaginary",
Imaginary: config.ImaginaryProcessorConfig{Url: "http://localhost"},
Imaginary: config.ImaginaryProcessorConfig{URL: "http://localhost"},
Cache: "none",
Redis: config.RedisCacheConfig{Url: ""},
Redis: config.RedisCacheConfig{URL: ""},
File: config.FileCacheConfig{Path: ""},
},
},
Expand All @@ -38,7 +38,7 @@ func TestNew(t *testing.T) {
},
{
name: "should not be able to init imaginary without valid url",
args: args{config.Config{Processor: "imaginary", Imaginary: config.ImaginaryProcessorConfig{Url: "localhost"}}},
args: args{config.Config{Processor: "imaginary", Imaginary: config.ImaginaryProcessorConfig{URL: "localhost"}}},
want: nil,
wantErr: true,
},
Expand All @@ -47,7 +47,7 @@ func TestNew(t *testing.T) {
args: args{
config.Config{
Processor: "imaginary",
Imaginary: config.ImaginaryProcessorConfig{Url: "htt://localhost"},
Imaginary: config.ImaginaryProcessorConfig{URL: "htt://localhost"},
},
},
want: nil,
Expand Down
4 changes: 2 additions & 2 deletions processor/imaginary.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func isValidURL(s string) error {

// NewImaginary instantiate a new imaginary instance with given config.
func NewImaginary(conf config.Config) (*ImaginaryProcessor, error) {
err := isValidURL(conf.Imaginary.Url)
err := isValidURL(conf.Imaginary.URL)
if err != nil {
return nil, err
}
Expand All @@ -67,7 +67,7 @@ func NewImaginary(conf config.Config) (*ImaginaryProcessor, error) {
client: http.Client{
Timeout: httpTimeout,
},
URL: conf.Imaginary.Url,
URL: conf.Imaginary.URL,
}, nil
}

Expand Down
1 change: 0 additions & 1 deletion processor/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ func (lp *LocalProcessor) Optimize(media []byte, of string, tf string, q, w int)
// if err != nil {
// return nil, err
// }

return media, tf, nil
}

0 comments on commit 7b11924

Please sign in to comment.