@@ -185,6 +185,47 @@ func TestCommandsInvokeUnmarshalsSlashCommandInvocationResult(t *testing.T) {
185185 }
186186}
187187
188+ func TestQueuedCommandResultBoolDiscriminatorJSONUnion (t * testing.T ) {
189+ stopProcessingQueue := true
190+ var handled QueuedCommandResult = & QueuedCommandHandled {StopProcessingQueue : & stopProcessingQueue }
191+ raw , err := json .Marshal (handled )
192+ if err != nil {
193+ t .Fatalf ("marshal handled result: %v" , err )
194+ }
195+ if string (raw ) != `{"handled":true,"stopProcessingQueue":true}` {
196+ t .Fatalf ("marshal handled result = %s" , raw )
197+ }
198+
199+ decodedHandled , err := unmarshalQueuedCommandResult ([]byte (`{"handled":true,"stopProcessingQueue":true}` ))
200+ if err != nil {
201+ t .Fatalf ("unmarshal handled result: %v" , err )
202+ }
203+ decodedHandledValue , ok := decodedHandled .(* QueuedCommandHandled )
204+ if ! ok {
205+ t .Fatalf ("unmarshal handled result = %T, want *QueuedCommandHandled" , decodedHandled )
206+ }
207+ if decodedHandledValue .StopProcessingQueue == nil || ! * decodedHandledValue .StopProcessingQueue {
208+ t .Fatalf ("unmarshal handled stopProcessingQueue = %v, want true" , decodedHandledValue .StopProcessingQueue )
209+ }
210+
211+ var notHandled QueuedCommandResult = & QueuedCommandNotHandled {}
212+ raw , err = json .Marshal (notHandled )
213+ if err != nil {
214+ t .Fatalf ("marshal not handled result: %v" , err )
215+ }
216+ if string (raw ) != `{"handled":false}` {
217+ t .Fatalf ("marshal not handled result = %s" , raw )
218+ }
219+
220+ decodedNotHandled , err := unmarshalQueuedCommandResult ([]byte (`{"handled":false}` ))
221+ if err != nil {
222+ t .Fatalf ("unmarshal not handled result: %v" , err )
223+ }
224+ if _ , ok := decodedNotHandled .(* QueuedCommandNotHandled ); ! ok {
225+ t .Fatalf ("unmarshal not handled result = %T, want *QueuedCommandNotHandled" , decodedNotHandled )
226+ }
227+ }
228+
188229func TestUIElicitationFieldValueJSONUnion (t * testing.T ) {
189230 raw , err := json .Marshal (UIElicitationBooleanValue (true ))
190231 if err != nil {
0 commit comments