Skip to content

Commit

Permalink
Merge pull request #1 from myokoo/change-version-type-to-string
Browse files Browse the repository at this point in the history
Change: LiteSpeedReport.Version type to string from float64
  • Loading branch information
myokoo authored Aug 27, 2019
2 parents 03044af + b07be13 commit 73144dd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## 0.1.1 / 2019-08-27
[Changed] LiteSpeedReport.Version to string from float64

## 0.1.0 / 2019-08-27

Initial release
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.1.1
4 changes: 2 additions & 2 deletions pkg/rtreport/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ func NewLineParser(lineTxt string) LineParser {

type versionLine string

// VERSION: LiteSpeed Web Server/Enterprise/x.x
// VERSION: LiteSpeed Web Server/Enterprise/x.x.x to x.x.x
func (v versionLine) parse(report *LiteSpeedReport) {
lineText := string(v)
if len(lineText) < 10 {
report.error = createTooShortParseLineError(lineText)
return
}
s := strings.Split(lineText, "/")
report.Version, report.error = strconv.ParseFloat(s[len(s)-1], 64)
report.Version = s[len(s)-1]
}

type uptimeLine string
Expand Down
8 changes: 4 additions & 4 deletions pkg/rtreport/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ func Test_versionLine_parse(t *testing.T) {
name string
v versionLine
args LiteSpeedReport
want float64
want string
wantErr bool
}{
{
name: "ok",
v: versionLine("VERSION: LiteSpeed Web Server/Enterprise/5.8"),
v: versionLine("VERSION: LiteSpeed Web Server/Enterprise/5.8.1"),
args: LiteSpeedReport{},
want: 5.8,
want: "5.8.1",
wantErr: false,
},
{
name: "ng",
v: versionLine("5.8"),
args: LiteSpeedReport{},
want: 0,
want: "",
wantErr: true,
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/rtreport/rtreport.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const (
// LiteSpeedReport
type LiteSpeedReport struct {
error error
Version float64
Version string
Uptime float64
NetworkReport map[string]float64
ConnectionReport map[string]float64
Expand Down
10 changes: 5 additions & 5 deletions pkg/rtreport/rtreport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Test_sum(t *testing.T) {
args: args{
a: &LiteSpeedReport{
Uptime: 123,
Version: 5.4,
Version: "5.4",
NetworkReport: map[string]float64{"BPS_IN": 123, "BPS_OUT": 713819, "SSL_BPS_IN": 136, "SSL_BPS_OUT": 891290},
ConnectionReport: map[string]float64{"MAXCONN": 10000, "MAXSSL_CONN": 5000, "PLAINCONN": 2331, "AVAILCONN": 7669, "IDLECONN": 0, "SSLCONN": 5, "AVAILSSL": 4995},
RequestReports: map[string]map[string]float64{
Expand All @@ -39,7 +39,7 @@ func Test_sum(t *testing.T) {
},
b: &LiteSpeedReport{
Uptime: 123,
Version: 5.4,
Version: "5.4",
NetworkReport: map[string]float64{"BPS_IN": 21213, "BPS_OUT": 343819, "SSL_BPS_IN": 123363, "SSL_BPS_OUT": 913290},
ConnectionReport: map[string]float64{"MAXCONN": 10000, "MAXSSL_CONN": 5000, "PLAINCONN": 1000, "AVAILCONN": 9000, "IDLECONN": 1, "SSLCONN": 100, "AVAILSSL": 4900},
RequestReports: map[string]map[string]float64{
Expand All @@ -56,7 +56,7 @@ func Test_sum(t *testing.T) {
},
want: &LiteSpeedReport{
Uptime: 123,
Version: 5.4,
Version: "5.4",
NetworkReport: map[string]float64{"BPS_IN": 21336, "BPS_OUT": 1057638, "SSL_BPS_IN": 123499, "SSL_BPS_OUT": 1804580},
ConnectionReport: map[string]float64{"MAXCONN": 20000, "MAXSSL_CONN": 10000, "PLAINCONN": 3331, "AVAILCONN": 16669, "IDLECONN": 1, "SSLCONN": 105, "AVAILSSL": 9895},
RequestReports: map[string]map[string]float64{
Expand Down Expand Up @@ -94,7 +94,7 @@ func Test_load(t *testing.T) {
name: "ok",
args: "../test/data/load/.rtreport",
want: &LiteSpeedReport{
Version: 5.4,
Version: "5.4",
Uptime: 56070,
NetworkReport: map[string]float64{"BPS_IN": 1, "BPS_OUT": 2, "SSL_BPS_IN": 3, "SSL_BPS_OUT": 4},
ConnectionReport: map[string]float64{"MAXCONN": 10000, "MAXSSL_CONN": 5000, "PLAINCONN": 0, "AVAILCONN": 10000, "IDLECONN": 0, "SSLCONN": 0, "AVAILSSL": 5000},
Expand Down Expand Up @@ -129,7 +129,7 @@ func TestNew(t *testing.T) {
name: "ok",
args: "../test/data/new",
want: &LiteSpeedReport{
Version: 5.4,
Version: "5.4",
Uptime: 56070,
NetworkReport: map[string]float64{"BPS_IN": 2, "BPS_OUT": 4, "SSL_BPS_IN": 6, "SSL_BPS_OUT": 8},
ConnectionReport: map[string]float64{"MAXCONN": 20000, "MAXSSL_CONN": 10000, "PLAINCONN": 0, "AVAILCONN": 20000, "IDLECONN": 0, "SSLCONN": 0, "AVAILSSL": 10000},
Expand Down

0 comments on commit 73144dd

Please sign in to comment.