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

Enhance error prompt while running go fn app locally #28

Open
bluezd opened this issue Jun 8, 2018 · 4 comments
Open

Enhance error prompt while running go fn app locally #28

bluezd opened this issue Jun 8, 2018 · 4 comments

Comments

@bluezd
Copy link

bluezd commented Jun 8, 2018

# fn init --runtime go hello
# go run func.go
panic: unknown format (fdk-go):

goroutine 1 [running]:
github.com/fnproject/fdk-go/utils.Do(0x14b3070, 0x128e178, 0x0, 0x0, 0x1380fe0, 0xc42000e010, 0x1381020, 0xc42000e018)
	/Users/jude/Programing/Go/Libraries/src/github.com/fnproject/fdk-go/utils/utils.go:51 +0x193
github.com/fnproject/fdk-go.Handle(0x1381a60, 0x128e178)
	/Users/jude/Programing/Go/Libraries/src/github.com/fnproject/fdk-go/fdk.go:81 +0xce
main.main()
	/Users/jude/Working/Oracle/Fn/apps/hello/func.go:14 +0x39
exit status 2

Fixing this issue is simple:

# export FN_FORMAT="default"
# echo '{"name": "Johnny"}' | ./func
{"message":"Hello Johnny"}

However for users who are totally new to the fn project they usually have no idea about what is going wrong there . They just wanna make sure their function works properly locally before building a fn app.

Shall we develop a patch in go FDK side for telling user what is going wrong there and how to fix it rather that a panic without any prompt ?

@denismakogon
Copy link
Member

Hi and welcome! Here's the thing. You actually allocated problematic area very explicitly, however, it not related to fdk-go.
If you'd like to test your function, you need to use the following commands:

fn test

or

fn run

Because the format env var is not the only var you'd need to set (there are at least 6 to 10 env vars FDK would need).

So, the thing you've done is not typic or even recommended path go. I recommend you to spend some time playing with interactive tutorial here: https://www.katacoda.com/fnproject/scenarios/fn-intro

@bluezd
Copy link
Author

bluezd commented Jun 8, 2018

I did fn test and fn run and it behaves normally. I am just wondering how to test the function locally, as you said it is not recommended. I got it. Thanks.

@denismakogon
Copy link
Member

Well. There have to be 2 ways to test your function:

  • fn test with a bunch of test suites
  • go test fixtures like FDK-java has (an extension to a native unit tests)

So, FDK-go misses the 2nd point. I'd better rename this issue to something in lines to:

Provide Go native testing framework for functions for sake of better coverage

@bluezd
Copy link
Author

bluezd commented Jun 8, 2018

Sure, agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants