From dc5d5ba398f114e3b3fa429282864192018cb5a0 Mon Sep 17 00:00:00 2001 From: Lee Spottiswood Date: Wed, 11 Mar 2020 12:49:15 +0000 Subject: [PATCH] remove workaround for asciigraph --- cmd/loadtest_job_results.go | 24 +++++++++--------------- go.mod | 2 +- go.sum | 2 ++ 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/cmd/loadtest_job_results.go b/cmd/loadtest_job_results.go index 7392808..0202f97 100644 --- a/cmd/loadtest_job_results.go +++ b/cmd/loadtest_job_results.go @@ -96,26 +96,20 @@ func loadtestJobResultsShow(service ltaas.LTaaSService, cmd *cobra.Command, args // generateGraph returns an ASCII graph for given parameters func generateGraph(graphWidth int, graphHeight int, graphCaption string, axisArray []ltaas.JobResultsAxis) string { - values, valid := getGraphValues(axisArray) - if !valid { - return "" - } - - return asciigraph.Plot(values, asciigraph.Caption(graphCaption), asciigraph.Width(graphWidth), asciigraph.Height(graphHeight)) + return asciigraph.Plot(getGraphValues(axisArray), asciigraph.Caption(graphCaption), asciigraph.Width(graphWidth), asciigraph.Height(graphHeight)) } -// getGraphValues returns the Y-axis values for provided axisArray, and a boolean indicating -// whether values are valid (contain at least 1 positive value), to workaround bug https://github.com/guptarohit/asciigraph/issues/17 -func getGraphValues(axisArray []ltaas.JobResultsAxis) ([]float64, bool) { +// getGraphValues returns the Y-axis values for provided axisArray, or a single value of 0 +// if no axis provided +func getGraphValues(axisArray []ltaas.JobResultsAxis) []float64 { + if len(axisArray) == 0 { + return []float64{0} + } + values := []float64{} - valid := false for _, axis := range axisArray { - if axis.Y > 0 { - valid = true - } - values = append(values, axis.Y) } - return values, valid + return values } diff --git a/go.mod b/go.mod index 97cc19d..3da9e0a 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ require ( github.com/blang/semver v3.5.1+incompatible github.com/golang/mock v1.2.0 github.com/google/uuid v1.1.1 - github.com/guptarohit/asciigraph v0.4.1 + github.com/guptarohit/asciigraph v0.4.2-0.20191006150553-f9506970428c github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334 github.com/mattn/go-runewidth v0.0.4 // indirect github.com/mitchellh/go-homedir v1.1.0 diff --git a/go.sum b/go.sum index 7ce2629..41a3f4d 100644 --- a/go.sum +++ b/go.sum @@ -28,6 +28,8 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/guptarohit/asciigraph v0.4.1 h1:YHmCMN8VH81BIUIgTg2Fs3B52QDxNZw2RQ6j5pGoSxo= github.com/guptarohit/asciigraph v0.4.1/go.mod h1:9fYEfE5IGJGxlP1B+w8wHFy7sNZMhPtn59f0RLtpRFM= +github.com/guptarohit/asciigraph v0.4.2-0.20191006150553-f9506970428c h1:lj/KuGMoYzVEYbzLoWLv7O4acsyH/K/qUxWbo/P70sU= +github.com/guptarohit/asciigraph v0.4.2-0.20191006150553-f9506970428c/go.mod h1:9fYEfE5IGJGxlP1B+w8wHFy7sNZMhPtn59f0RLtpRFM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=