github.com/argoproj/argo-events@v1.9.1/metrics/metrics_test.go (about)

     1  package metrics
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  	"net/http"
     7  	"testing"
     8  	"time"
     9  
    10  	"github.com/stretchr/testify/assert"
    11  
    12  	"github.com/argoproj/argo-events/common/logging"
    13  )
    14  
    15  func TestRun(t *testing.T) {
    16  	port := 9090
    17  	m := NewMetrics("test-ns")
    18  	go m.Run(logging.WithLogger(context.Background(), logging.NewArgoEventsLogger()), fmt.Sprintf(":%d", port))
    19  	time.Sleep(1 * time.Second)
    20  	resp, err := http.Get(fmt.Sprintf("http://localhost:%d/metrics", port))
    21  	assert.Nil(t, err)
    22  	assert.Equal(t, resp.StatusCode, 200)
    23  }