Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
FredrikOseberg committed Jul 8, 2022
1 parent 0f16664 commit e6f0f1a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 33 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ func (uc *Client) isEnabled(feature string, options ...FeatureOption) (enabled b
}

segmentConstraints, err := uc.repository.resolveSegmentConstraints(s)

if err != nil {
uc.errors <- err
return false;
return false
}

allConstraints := make([]api.Constraint, 0)
Expand Down
52 changes: 24 additions & 28 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ func TestClient_WithSegment(t *testing.T) {
WithInstanceId(mockInstanceId),
WithListener(mockListener),
)

assert.NoError(err)
client.WaitForReady()

isEnabled := client.IsEnabled(feature, WithContext(context.Context{
Properties: map[string]string{"custom-id": "custom-ctx"},
}))
Expand Down Expand Up @@ -417,8 +417,6 @@ func TestClient_WithNonExistingSegment(t *testing.T) {
},
}



gock.New(mockerServer).
Get("/client/features").
Reply(200).
Expand All @@ -432,8 +430,6 @@ func TestClient_WithNonExistingSegment(t *testing.T) {
mockListener.On("OnCount", feature, false).Return()
mockListener.On("OnError", mock.AnythingOfType("*errors.errorString"))



client, err := NewClient(
WithUrl(mockerServer),
WithAppName(mockAppName),
Expand All @@ -448,7 +444,7 @@ func TestClient_WithNonExistingSegment(t *testing.T) {
isEnabled := client.IsEnabled(feature, WithContext(context.Context{
Properties: map[string]string{"custom-id": "custom-ctx"},
}))

assert.False(isEnabled)

assert.True(gock.IsDone(), "there should be no more mocks")
Expand Down Expand Up @@ -499,23 +495,23 @@ func TestClient_WithMultipleSegments(t *testing.T) {
Operator: api.OperatorIn,
Values: []string{"custom-ctx"},
}}},
{Id: 2, Constraints: []api.Constraint{
{Id: 2, Constraints: []api.Constraint{
{
ContextName: "semver",
Operator: api.OperatorSemverGt,
Value: "3.2.1",
Value: "3.2.1",
}}},
{Id: 4, Constraints: []api.Constraint{
{Id: 4, Constraints: []api.Constraint{
{
ContextName: "age",
Operator: api.OperatorNumEq,
Value: "18",
}}},
{Id: 6, Constraints: []api.Constraint{
{Id: 6, Constraints: []api.Constraint{
{
ContextName: "domain",
Operator: api.OperatorStrStartsWith,
Values: []string{"unleash"},
Values: []string{"unleash"},
}}},
}})

Expand All @@ -531,12 +527,12 @@ func TestClient_WithMultipleSegments(t *testing.T) {
WithInstanceId(mockInstanceId),
WithListener(mockListener),
)

assert.NoError(err)
client.WaitForReady()

fmt.Printf("%v", client.repository.segments)

isEnabled := client.IsEnabled(feature, WithContext(context.Context{
Properties: map[string]string{"custom-id": "custom-ctx", "semver": "3.2.2", "age": "18", "domain": "unleashtest"},
}))
Expand Down Expand Up @@ -603,23 +599,23 @@ func TestClient_VariantShouldRespectConstraint(t *testing.T) {
Operator: api.OperatorIn,
Values: []string{"custom-ctx"},
}}},
{Id: 2, Constraints: []api.Constraint{
{Id: 2, Constraints: []api.Constraint{
{
ContextName: "semver",
Operator: api.OperatorSemverGt,
Value: "3.2.1",
Value: "3.2.1",
}}},
{Id: 4, Constraints: []api.Constraint{
{Id: 4, Constraints: []api.Constraint{
{
ContextName: "age",
Operator: api.OperatorNumEq,
Value: "18",
}}},
{Id: 6, Constraints: []api.Constraint{
{Id: 6, Constraints: []api.Constraint{
{
ContextName: "domain",
Operator: api.OperatorStrStartsWith,
Values: []string{"unleash"},
Values: []string{"unleash"},
}}},
}})

Expand All @@ -635,12 +631,12 @@ func TestClient_VariantShouldRespectConstraint(t *testing.T) {
WithInstanceId(mockInstanceId),
WithListener(mockListener),
)

assert.NoError(err)
client.WaitForReady()

fmt.Printf("%v", client.repository.segments)

variant := client.GetVariant(feature, WithVariantContext(context.Context{
Properties: map[string]string{"custom-id": "custom-ctx", "semver": "3.2.2", "age": "18", "domain": "unleashtest"},
}))
Expand Down Expand Up @@ -707,23 +703,23 @@ func TestClient_VariantShouldFailWhenSegmentConstraintsDontMatch(t *testing.T) {
Operator: api.OperatorIn,
Values: []string{"custom-ctx"},
}}},
{Id: 2, Constraints: []api.Constraint{
{Id: 2, Constraints: []api.Constraint{
{
ContextName: "semver",
Operator: api.OperatorSemverGt,
Value: "3.2.1",
Value: "3.2.1",
}}},
{Id: 4, Constraints: []api.Constraint{
{Id: 4, Constraints: []api.Constraint{
{
ContextName: "age",
Operator: api.OperatorNumEq,
Value: "15",
}}},
{Id: 6, Constraints: []api.Constraint{
{Id: 6, Constraints: []api.Constraint{
{
ContextName: "domain",
Operator: api.OperatorStrStartsWith,
Values: []string{"unleash"},
Values: []string{"unleash"},
}}},
}})

Expand All @@ -738,12 +734,12 @@ func TestClient_VariantShouldFailWhenSegmentConstraintsDontMatch(t *testing.T) {
WithInstanceId(mockInstanceId),
WithListener(mockListener),
)

assert.NoError(err)
client.WaitForReady()

fmt.Printf("%v", client.repository.segments)

variant := client.GetVariant(feature, WithVariantContext(context.Context{
Properties: map[string]string{"custom-id": "custom-ctx", "semver": "3.2.2", "age": "18", "domain": "unleashtest"},
}))
Expand Down
2 changes: 0 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,3 @@ type metricsOptions struct {
httpClient *http.Client
customHeaders http.Header
}


1 change: 0 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ func getFetchURLPath(projectName string) string {
}
return "./client/features"
}

0 comments on commit e6f0f1a

Please sign in to comment.