Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestEnv.ClientRes.Status is not behaving as expected when ExitStatus is called. #163

Closed
at-silva opened this issue Nov 3, 2023 · 4 comments · May be fixed by #164
Closed

TestEnv.ClientRes.Status is not behaving as expected when ExitStatus is called. #163

at-silva opened this issue Nov 3, 2023 · 4 comments · May be fixed by #164
Labels
bug Something isn't working

Comments

@at-silva
Copy link

at-silva commented Nov 3, 2023

Steps to reproduce:

lab.go:

package golab45

import (
	"net/http"

	"github.com/Kong/go-pdk"
)

type (
	Config struct {
	}
)

func (c *Config) Access(kong *pdk.PDK) {
	kong.Response.ExitStatus(http.StatusBadRequest)
}

lab_test.go:

package golab45_test

import (
	"golab45"
	"net/http"
	"testing"

	"github.com/Kong/go-pdk/test"
)

func Test(t *testing.T) {
	env, _ := test.New(t, test.Request{Method: http.MethodGet, Url: "http://example.com"})
	env.DoHttp(&golab45.Config{})
	if env.ClientRes.Status != http.StatusBadRequest {
		t.Errorf("expected %d got %d", http.StatusBadRequest, env.ClientRes.Status)
	}
}

test output:

Running tool: /usr/local/go/bin/go test -timeout 30s -run ^Test$ golab45

--- FAIL: Test (0.00s)
    ./test.go:579: Access
    ./lab_test.go:15: expected 400 got 200
FAIL
FAIL	golab45	0.003s
FAIL

@gszr
Copy link
Member

gszr commented Feb 22, 2024

Possibly related to #119

@gszr gszr added the bug Something isn't working label Feb 22, 2024
@gszr
Copy link
Member

gszr commented Feb 22, 2024

Thank you for the repro sample.

@StarlightIbuki
Copy link
Contributor

Internally tracked: KAG-3813
I agree it should be related to #119

@gszr
Copy link
Member

gszr commented Mar 12, 2024

This issue is fixed as of version v0.10.2; please give it a try! Closing the issue for now. Thank you for taking the time to report!

@gszr gszr closed this as completed Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants