Skip to content

Commit

Permalink
Adding some test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gfleury committed Sep 20, 2019
1 parent 82a231f commit 0f08a3b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 0 additions & 2 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ func main() {
fmt.Println(err)
os.Exit(1)
}

break

}
}
if o == nil {
Expand Down
33 changes: 33 additions & 0 deletions output/output_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package output

import (
"fmt"
"github.com/gfleury/gstreamtop/conf"
"github.com/gfleury/gstreamtop/tablestream"
"github.com/prometheus/client_golang/prometheus/promhttp"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -91,3 +94,33 @@ func (s *Suite) TestPrometheus(c *check.C) {
}

}

func (s *Suite) TestOutput(c *check.C) {
conf := &conf.Configuration{}

conf.SetFileURL("../mapping.yaml")
err := conf.ReadFile()
if err != nil {
fmt.Println(err)
os.Exit(1)
}

o := &StreamOutput{}
err = o.CreateStreamFromConfigurationMapping(&conf.Mappings[0], nil)
c.Assert(err, check.IsNil)

a := true

o.SetInputExists(func() *bool {
return &a
})
exists := o.InputExists()
c.Assert(*exists, check.Equals, true)

a = false
exists = o.InputExists()
c.Assert(*exists, check.Equals, false)

b := o.Stream()
c.Assert(b, check.NotNil)
}

0 comments on commit 0f08a3b

Please sign in to comment.