echox icon indicating copy to clipboard operation
echox copied to clipboard

guide testing example FAIL ; actual has additional "\n" symbol in the end of string.

Open likejehu opened this issue 4 years ago • 3 comments

hey, I'm a beginner, studying golang testing example produce this result:

Running tool: C:\Go\bin\go.exe test -timeout 30s github.com\likejehu\xpl -run ^(TestCreateUser)$

--- FAIL: TestCreateUser (0.00s) c:\Users\aart\go\src\github.com\likejehu\xpl\handler_test.go:32: Error Trace: handler_test.go:32 Error: Not equal: expected: "{"name":"Jon Snow","email":"[email protected]"}" actual : "{"name":"Jon Snow","email":"[email protected]"}\n"

    	            	Diff:
    	            	--- Expected
    	            	+++ Actual
    	            	@@ -1 +1,2 @@
    	            	 {"name":"Jon Snow","email":"[email protected]"}
    	            	+
    	Test:       	TestCreateUser

FAIL FAIL github.com/likejehu/xpl 0.364s FAIL Error: Tests failed.

is it okay?

can anyone explain me why we have "{"name":"Jon Snow","email":"[email protected]"}\n" this as actual string after calling handler func, whith "\n" at the end?

likejehu avatar Feb 28 '20 22:02 likejehu

Same for me

s0j0hn avatar May 02 '20 13:05 s0j0hn

Same for me.

I think this line should be something like this.

	userJSON = "{\"name\":\"Jon Snow\",\"email\":\"[email protected]\"}\n"

TakuKaneda avatar Mar 01 '21 01:03 TakuKaneda

same for me

tamago0224 avatar Aug 24 '21 16:08 tamago0224