github.com/status-im/status-go@v1.1.0/protocol/requests/add_centralized_metric_test.go (about)

     1  package requests
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  
     8  	"github.com/status-im/status-go/centralizedmetrics/common"
     9  )
    10  
    11  func TestValidateAddCentralizedMetrics(t *testing.T) {
    12  	tests := []struct {
    13  		name          string
    14  		request       AddCentralizedMetric
    15  		expectedError error
    16  	}{
    17  		{
    18  			name: "valid metric",
    19  			request: AddCentralizedMetric{
    20  				Metric: &common.Metric{EventName: "event-name", Platform: "android", AppVersion: "version"},
    21  			},
    22  			expectedError: nil,
    23  		},
    24  		{
    25  			name:          "empty metric",
    26  			expectedError: ErrAddCentralizedMetricInvalidMetric,
    27  		},
    28  	}
    29  
    30  	for _, tt := range tests {
    31  		t.Run(tt.name, func(t *testing.T) {
    32  			err := tt.request.Validate()
    33  			require.Equal(t, tt.expectedError, err)
    34  		})
    35  	}
    36  }