diff --git a/cloudflare/queues/consumermessage.go b/cloudflare/queues/consumermessage.go index e1f2bec..b0e1203 100644 --- a/cloudflare/queues/consumermessage.go +++ b/cloudflare/queues/consumermessage.go @@ -80,19 +80,3 @@ func (m *ConsumerMessage) BytesBody() ([]byte, error) { return nil, fmt.Errorf("message body is not a byte array: %v", m.Body) } - -func (m *ConsumerMessage) IntBody() (int, error) { - if m.Body.Type() == js.TypeNumber { - return m.Body.Int(), nil - } - - return 0, fmt.Errorf("message body is not a number: %v", m.Body) -} - -func (m *ConsumerMessage) FloatBody() (float64, error) { - if m.Body.Type() == js.TypeNumber { - return m.Body.Float(), nil - } - - return 0, fmt.Errorf("message body is not a number: %v", m.Body) -} diff --git a/cloudflare/queues/consumermessage_test.go b/cloudflare/queues/consumermessage_test.go index c285ee2..909c0cd 100644 --- a/cloudflare/queues/consumermessage_test.go +++ b/cloudflare/queues/consumermessage_test.go @@ -225,97 +225,3 @@ func TestConsumerMessage_BytesBody(t *testing.T) { }) } } - -func TestConsumerMessage_IntBody(t *testing.T) { - tests := []struct { - name string - body js.Value - want int - wantErr bool - }{ - { - name: "int", - body: js.ValueOf(42), - want: 42, - }, - { - name: "float", - body: js.ValueOf(42.5), - want: 42, - }, - { - name: "string", - body: js.ValueOf("42"), - wantErr: true, - }, - { - name: "undefined", - body: js.Undefined(), - wantErr: true, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - m := &ConsumerMessage{ - Body: tt.body, - } - - got, err := m.IntBody() - if (err != nil) != tt.wantErr { - t.Fatalf("IntBody() error = %v, wantErr %v", err, tt.wantErr) - } - - if got != tt.want { - t.Fatalf("IntBody() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestConsumerMessage_FloatBody(t *testing.T) { - tests := []struct { - name string - body js.Value - want float64 - wantErr bool - }{ - { - name: "int", - body: js.ValueOf(42), - want: 42.0, - }, - { - name: "float", - body: js.ValueOf(42.5), - want: 42.5, - }, - { - name: "string", - body: js.ValueOf("42"), - wantErr: true, - }, - { - name: "undefined", - body: js.Undefined(), - wantErr: true, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - m := &ConsumerMessage{ - Body: tt.body, - } - - got, err := m.FloatBody() - if (err != nil) != tt.wantErr { - t.Fatalf("FloatBody() error = %v, wantErr %v", err, tt.wantErr) - } - - if got != tt.want { - t.Fatalf("FloatBody() = %v, want %v", got, tt.want) - } - }) - } -}