chore: import upstream snapshot with attribution
govulncheck / govulncheck (push) Has been cancelled
Lint / golangci-lint (push) Has been cancelled
Run Tests / Unit Tests (push) Has been cancelled
Run Tests / Etcd Integration Tests (push) Has been cancelled
Harness (E2E) / Harnesses (mock LLM) (push) Has been cancelled
Harness (E2E) / Provider harnesses (live LLM conformance) (push) Has been cancelled
govulncheck / govulncheck (push) Has been cancelled
Lint / golangci-lint (push) Has been cancelled
Run Tests / Unit Tests (push) Has been cancelled
Run Tests / Etcd Integration Tests (push) Has been cancelled
Harness (E2E) / Harnesses (mock LLM) (push) Has been cancelled
Harness (E2E) / Provider harnesses (live LLM conformance) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package wrapper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"go-micro.dev/v6/metadata"
|
||||
)
|
||||
|
||||
func TestWrapper(t *testing.T) {
|
||||
testData := []struct {
|
||||
existing metadata.Metadata
|
||||
headers metadata.Metadata
|
||||
overwrite bool
|
||||
}{
|
||||
{
|
||||
existing: metadata.Metadata{},
|
||||
headers: metadata.Metadata{
|
||||
"Foo": "bar",
|
||||
},
|
||||
overwrite: true,
|
||||
},
|
||||
{
|
||||
existing: metadata.Metadata{
|
||||
"Foo": "bar",
|
||||
},
|
||||
headers: metadata.Metadata{
|
||||
"Foo": "baz",
|
||||
},
|
||||
overwrite: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, d := range testData {
|
||||
c := &fromServiceWrapper{
|
||||
headers: d.headers,
|
||||
}
|
||||
|
||||
ctx := metadata.NewContext(context.Background(), d.existing)
|
||||
ctx = c.setHeaders(ctx)
|
||||
md, _ := metadata.FromContext(ctx)
|
||||
|
||||
for k, v := range d.headers {
|
||||
if d.overwrite && md[k] != v {
|
||||
t.Fatalf("Expected %s=%s got %s=%s", k, v, k, md[k])
|
||||
}
|
||||
if !d.overwrite && md[k] != d.existing[k] {
|
||||
t.Fatalf("Expected %s=%s got %s=%s", k, d.existing[k], k, md[k])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user