Skip to content

Commit

Permalink
cover more lines
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalcaliskan committed Jan 9, 2022
1 parent 45e5c1c commit 4fe0f04
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ vendor/
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*.out
coverage.txt
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/prometheus/client_golang v1.11.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.20.0
Expand Down
8 changes: 3 additions & 5 deletions internal/logging/logging_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package logging

import (
"go.uber.org/zap"
"github.com/stretchr/testify/assert"
"testing"
)

func TestGetLogger(t *testing.T) {
_, err := zap.NewProduction()
if err != nil {
t.Errorf("%v\n", err.Error())
}
logger := GetLogger()
assert.NotNil(t, logger)
}
17 changes: 1 addition & 16 deletions internal/metrics/metrics_test.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
package metrics

import (
"fmt"
"net/http"
"testing"
"time"

"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.uber.org/zap"
)

func TestRunMetricsServer(t *testing.T) {
errChan := make(chan error, 1)

go func() {
router := mux.NewRouter()
metricServer := &http.Server{
Handler: router,
Addr: fmt.Sprintf(":%d", opts.MetricsPort),
WriteTimeout: time.Duration(int32(opts.WriteTimeoutSeconds)) * time.Second,
ReadTimeout: time.Duration(int32(opts.ReadTimeoutSeconds)) * time.Second,
}
router.Handle("/metrics", promhttp.Handler())
logger.Info("starting metrics server", zap.Int("port", opts.MetricsPort))
errChan <- metricServer.ListenAndServe()
errChan <- RunMetricsServer()
}()

for {
Expand Down
14 changes: 14 additions & 0 deletions internal/options/options_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package options

import (
"github.com/stretchr/testify/assert"
"testing"
)

// TestGetOreillyTrialOptions function tests if GetOreillyTrialOptions function running properly
func TestGetVarnishCacheInvalidatorOptions(t *testing.T) {
t.Log("fetching default options.VarnishCacheInvalidatorOptions")
opts := GetVarnishCacheInvalidatorOptions()
assert.NotNil(t, opts)
t.Logf("fetched default options.VarnishCacheInvalidatorOptions, %v\n", opts)
}

0 comments on commit 4fe0f04

Please sign in to comment.