1package config23import (4 "context"5 "reflect"6 "testing"7)89func TestBadFromContext(t *testing.T) {10 ctx := context.TODO()11 if c := FromContext(ctx); c != nil {12 t.Errorf("FromContext(ctx) => %v, want %v", c, nil)13 }14}1516func TestGoodFromContext(t *testing.T) {17 ctx := WithContext(context.TODO(), &Config{})18 if c := FromContext(ctx); c == nil {19 t.Errorf("FromContext(ctx) => %v, want %v", c, &Config{})20 }21}2223func TestGoodFromContextWithDefaultConfig(t *testing.T) {24 cfg := DefaultConfig()25 ctx := WithContext(context.TODO(), cfg)26 if c := FromContext(ctx); c == nil || !reflect.DeepEqual(c, cfg) {27 t.Errorf("FromContext(ctx) => %v, want %v", c, cfg)28 }29}