package config import ( "context" "testing" ) func TestFromCtx(t *testing.T) { app := &AppConfig{ Name: "testapp", } appCtx := app.AddToCtx(context.Background()) type args struct { ctx context.Context } tests := []struct { name string args args wantErr bool }{ { name: "Unprepared app context", args: args{ctx: context.Background()}, wantErr: true, }, { name: "Prepared app context", args: args{ctx: appCtx}, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { _, err := FromCtx(tt.args.ctx) if (err != nil) != tt.wantErr { t.Errorf("FromCtx() error = %v, wantErr %v", err, tt.wantErr) return } }) } }