Skip to content

Commit

Permalink
chore: return an empty metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Aguilar <[email protected]>
  • Loading branch information
thepabloaguilar committed Jul 26, 2024
1 parent 0933706 commit ceef795
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
10 changes: 6 additions & 4 deletions internal/server/ofrep/evaluation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ofrep

import (
"context"

flipterrors "go.flipt.io/flipt/errors"
"go.uber.org/zap"

Expand Down Expand Up @@ -46,10 +47,11 @@ func (s *Server) EvaluateFlag(ctx context.Context, r *ofrep.EvaluateFlagRequest)
}

resp := &ofrep.EvaluatedFlag{
Key: output.FlagKey,
Reason: transformReason(output.Reason),
Variant: output.Variant,
Value: value,
Key: output.FlagKey,
Reason: transformReason(output.Reason),
Variant: output.Variant,
Value: value,
Metadata: &structpb.Struct{Fields: make(map[string]*structpb.Value)},
}

s.logger.Debug("ofrep variant", zap.Stringer("response", resp))
Expand Down
21 changes: 12 additions & 9 deletions internal/server/ofrep/evaluation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package ofrep

import (
"context"
"testing"

"github.com/stretchr/testify/mock"
flipterrors "go.flipt.io/flipt/errors"
"google.golang.org/grpc/codes"
"testing"

"google.golang.org/grpc/metadata"

Expand All @@ -24,10 +25,11 @@ func TestEvaluateFlag_Success(t *testing.T) {
ctx := context.TODO()
flagKey := "flag-key"
expectedResponse := &ofrep.EvaluatedFlag{
Key: flagKey,
Reason: ofrep.EvaluateReason_DEFAULT,
Variant: "false",
Value: structpb.NewBoolValue(false),
Key: flagKey,
Reason: ofrep.EvaluateReason_DEFAULT,
Variant: "false",
Value: structpb.NewBoolValue(false),
Metadata: &structpb.Struct{Fields: make(map[string]*structpb.Value)},
}
bridge := &bridgeMock{}
s := New(zaptest.NewLogger(t), config.CacheConfig{}, bridge)
Expand Down Expand Up @@ -62,10 +64,11 @@ func TestEvaluateFlag_Success(t *testing.T) {
}))
flagKey := "flag-key"
expectedResponse := &ofrep.EvaluatedFlag{
Key: flagKey,
Reason: ofrep.EvaluateReason_DISABLED,
Variant: "true",
Value: structpb.NewBoolValue(true),
Key: flagKey,
Reason: ofrep.EvaluateReason_DISABLED,
Variant: "true",
Value: structpb.NewBoolValue(true),
Metadata: &structpb.Struct{Fields: make(map[string]*structpb.Value)},
}
bridge := &bridgeMock{}
s := New(zaptest.NewLogger(t), config.CacheConfig{}, bridge)
Expand Down

0 comments on commit ceef795

Please sign in to comment.