-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix after project rename * Add unit tests * More unit testing testing * Prepare for public
- Loading branch information
Showing
17 changed files
with
581 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
func TestConfig_overWriteFromLine(t *testing.T) { | ||
type args struct { | ||
server string | ||
path string | ||
} | ||
type fields struct { | ||
Server string | ||
Path string | ||
Days int | ||
Jobs []string | ||
Step int | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
args args | ||
expect args | ||
}{ | ||
{"none", fields{"server.local", "/my", 1, nil, 10}, args{}, args{"server.local", "/my"}}, | ||
{"server", fields{"server.local", "/my", 1, nil, 10}, args{"server.new", ""}, args{"server.new", "/my"}}, | ||
{"path", fields{"server.local", "/my", 1, nil, 10}, args{"", "/newPath"}, args{"server.local", "/newPath"}}, | ||
{"both", fields{"server.local", "/my", 1, nil, 10}, args{"server.new", "/newPath"}, args{"server.new", "/newPath"}}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
c := &Config{ | ||
Server: tt.fields.Server, | ||
Path: tt.fields.Path, | ||
Days: tt.fields.Days, | ||
Jobs: tt.fields.Jobs, | ||
Step: tt.fields.Step, | ||
} | ||
server = &tt.args.server | ||
directoryData = &tt.args.path | ||
c.overWriteFromLine() | ||
if c.Server != tt.expect.server { | ||
t.Errorf("overWriteFromLine() = server %s, want %s", c.Server, tt.expect.server) | ||
} | ||
if c.Path != tt.expect.path { | ||
t.Errorf("overWriteFromLine() = path %s, want %s", c.Path, tt.expect.path) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestConfig_validate(t *testing.T) { | ||
type fields struct { | ||
Server string | ||
Path string | ||
Days int | ||
Jobs []string | ||
Step int | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
wantErr bool | ||
}{ | ||
{"all valid", fields{"server.local", "./", 2, nil, 10}, false}, | ||
{"no server", fields{"", "./", 2, nil, 10}, true}, | ||
{"no path", fields{"", "", 2, nil, 10}, true}, | ||
{"wrong day", fields{"", "./", -2, nil, 10}, true}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
c := &Config{ | ||
Server: tt.fields.Server, | ||
Path: tt.fields.Path, | ||
Days: tt.fields.Days, | ||
Jobs: tt.fields.Jobs, | ||
Step: tt.fields.Step, | ||
} | ||
if err := c.validate(); (err != nil) != tt.wantErr { | ||
t.Errorf("validate() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
module github.com/pokornyIt/prometehus_export | ||
module github.com/pokornyIt/prometehus_data_dump | ||
|
||
go 1.14 | ||
|
||
require ( | ||
github.com/go-kit/kit v0.9.0 | ||
github.com/opentracing/opentracing-go v1.1.0 // indirect | ||
github.com/prometheus/client_golang v1.0.0 | ||
github.com/prometheus/common v0.10.0 | ||
github.com/prometheus/prometheus v2.5.0+incompatible // indirect | ||
github.com/prometheus/tsdb v0.10.0 // indirect | ||
gopkg.in/alecthomas/kingpin.v2 v2.2.6 | ||
gopkg.in/yaml.v2 v2.2.5 | ||
) |
Oops, something went wrong.