TibiaData/tibiadata-api-go

Fix codecov test issues

tobiasehlert opened this issue · 2 comments

When codecov workflow executes, it throws 3 errors saying it receives Bad Request from upstream.

=== RUN   TestFakeToUpCodeCoverage
Warning: 2023/10/09 11:23:24 [warning] TibiaCreaturesCreatureImpl called on invalid creature
    webserver_test.go:65: 
        	Error Trace:	/home/runner/work/tibiadata-api-go/tibiadata-api-go/src/webserver_test.go:65
        	Error:      	Not equal: 
        	            	expected: 200
        	            	actual  : 400
        	Test:       	TestFakeToUpCodeCoverage
    webserver_test.go:85: 
        	Error Trace:	/home/runner/work/tibiadata-api-go/tibiadata-api-go/src/webserver_test.go:85
        	Error:      	Not equal: 
        	            	expected: 200
        	            	actual  : 400
        	Test:       	TestFakeToUpCodeCoverage
    webserver_test.go:124: 
        	Error Trace:	/home/runner/work/tibiadata-api-go/tibiadata-api-go/src/webserver_test.go:124
        	Error:      	Not equal: 
        	            	expected: 200
        	            	actual  : 400
        	Test:       	TestFakeToUpCodeCoverage
--- FAIL: TestFakeToUpCodeCoverage (1.86s)

When adding print of c (c, _ = gin.CreateTestContext(w)) and w (w = httptest.NewRecorder()) it looks like this..

tibiaCreaturesCreature

c:
&{{0xc000084c40 174 400} <nil> 0xc00012c200 [{race demon}] [] -1  0xc000082d00 0xc0000b85e8 0xc0000b8600 {{0 0} 0 0 {{} 0} {{} 0}} map[]  [] map[] map[] 0}

w:
&{400 map[Content-Type:[application/json; charset=utf-8]] {"information":{"api":{"version":0,"release":"","commit":""},"timestamp":"2023-10-09T12:26:42Z","status":{"http_code":400,"error":20002,"message":"could not find creature"}}} false <nil> map[Content-Type:[application/json; charset=utf-8]] true}

tibiaGuildsGuild

c:
&{{0xc000084f80 171 400} <nil> 0xc0004c0f00 [{name pax}] [] -1  0xc0005a31e0 0xc00036ffe0 0xc0004ea000 {{0 0} 0 0 {{} 0} {{} 0}} map[]  [] map[] map[] 0}

w:
&{400 map[Content-Type:[application/json; charset=utf-8]] {"information":{"api":{"version":0,"release":"","commit":""},"timestamp":"2023-10-09T12:26:42Z","status":{"http_code":400,"error":20004,"message":"could not find guild"}}} false <nil> map[Content-Type:[application/json; charset=utf-8]] true}

tibiaHighscores

c:
&{{0xc000084b00 203 400} <nil> 0xc00012c400 [{world antica} {category experience} {vocation sorcerer} {page 4}] [] -1  0xc000082d00 0xc0004ea228 0xc0004ea240 {{0 0} 0 0 {{} 0} {{} 0}} map[]  [] map[] map[] 0}

w:
&{400 map[Content-Type:[application/json; charset=utf-8]] {"information":{"api":{"version":0,"release":"","commit":""},"timestamp":"2023-10-09T12:26:42Z","status":{"http_code":400,"error":11008,"message":"the provided page is larger than max amount of pages"}}} false <nil> map[Content-Type:[application/json; charset=utf-8]] true}

Added outputs in following commits d64903b, 9271f64 and 3602f04.

To be reverted later when finished with testing.

Workflow doesn't have permissions required to access secrets since they are coming from a fork, which are required to connect to tibiadata's network.

Possible solution would be to trigger workflow by a command (eg. /codecov), but we don't have such thing implemented for now.

Workaround for now is for a tibiadata-developer to trigger codecov instead by pushing to branch.