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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEVEL] The testable example "ExampleRun" is incorrectly passing #5066

Closed
ameowlia opened this issue Sep 21, 2021 · 2 comments
Closed

[DEVEL] The testable example "ExampleRun" is incorrectly passing #5066

ameowlia opened this issue Sep 21, 2021 · 2 comments
Labels
investigating Needs someone to take a deeper look. Has been viewed and someone will figure out the procedure.

Comments

@ameowlia
Copy link

馃憢 Hello,

I am investigating the golang issue: golang/go#48362, where testable examples are causing false positives when the output comment block is not the last comment block example.

I ran a parser against the top golang repos, including this repo, and I found this bug with the ExampleRun testable example.

The comment blocks should be combined into one comment block like so:

func ExampleRun() {
	t := &testing.T{}
	tc := cltest.NewTestGeneralConfig(t)
	tc.Overrides.Dev = null.BoolFrom(false)
	testClient := &cmd.Client{
		Renderer:               cmd.RendererTable{Writer: ioutil.Discard},
		Config:                 tc,
		AppFactory:             cmd.ChainlinkAppFactory{},
		FallbackAPIInitializer: &cltest.MockAPIInitializer{},
		Runner:                 cmd.ChainlinkRunner{},
		HTTP:                   cltest.NewMockAuthenticatedHTTPClient(tc, "session"),
		ChangePasswordPrompter: cltest.MockChangePasswordPrompter{},
	}

	Run(testClient, "core.test", "--help")
	Run(testClient, "core.test", "--version")
	// Output:
	// NAME:
	//    core.test - CLI for Chainlink
	//
	// USAGE:
	//    core.test [global options] command [command options] [arguments...]
	//
	// VERSION:
	//    unset@unset
	//
	// COMMANDS:
	//    admin           Commands for remotely taking admin related actions
	//    attempts, txas  Commands for managing Ethereum Transaction Attempts
	//    bridges         Commands for Bridges communicating with External Adapters
	//    config          Commands for the node's configuration
	//    jobs            Commands for managing Jobs
	//    keys            Commands for managing various types of keys used by the Chainlink node
	//    node, local     Commands for admin actions that must be run locally
	//    runs            Commands for managing Runs
	//    txs             Commands for handling Ethereum transactions
	//    help, h         Shows a list of commands or help for one command
	//
	// GLOBAL OPTIONS:
	//    --json, -j     json output as opposed to table
	//    --help, -h     show help
	//    --version, -v  print the version
	// core.test version unset@unset
}

When I fixed it so that it would check the output I got the following test failure:

$ DATABASE_URL="meow_test" go test .
--- FAIL: ExampleRun (0.00s)
got:
NAME:
   core.test - CLI for Chainlink

USAGE:
   core.test [global options] command [command options] [arguments...]

VERSION:
   unset@unset

COMMANDS:
   admin           Commands for remotely taking admin related actions
   attempts, txas  Commands for managing Ethereum Transaction Attempts
   blocks          Commands for managing blocks
   bridges         Commands for Bridges communicating with External Adapters
   config          Commands for the node's configuration
   jobs            Commands for managing Jobs (V2)
   keys            Commands for managing various types of keys used by the Chainlink node
   node, local     Commands for admin actions that must be run locally
   txs             Commands for handling Ethereum transactions
   chains          Commands for handling chain configuration
   nodes           Commands for handling node configuration
   help, h         Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --json, -j     json output as opposed to table
   --help, -h     show help
   --version, -v  print the version
core.test version unset@unset
want:
NAME:
   core.test - CLI for Chainlink

USAGE:
   core.test [global options] command [command options] [arguments...]

VERSION:
   unset@unset

COMMANDS:
   admin           Commands for remotely taking admin related actions
   attempts, txas  Commands for managing Ethereum Transaction Attempts
   bridges         Commands for Bridges communicating with External Adapters
   config          Commands for the node's configuration
   jobs            Commands for managing Jobs
   keys            Commands for managing various types of keys used by the Chainlink node
   node, local     Commands for admin actions that must be run locally
   runs            Commands for managing Runs
   txs             Commands for handling Ethereum transactions
   help, h         Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --json, -j     json output as opposed to table
   --help, -h     show help
   --version, -v  print the version
core.test version unset@unset
FAIL
FAIL    github.com/smartcontractkit/chainlink/core      0.226s
FAIL
@ZakAyesh ZakAyesh added the investigating Needs someone to take a deeper look. Has been viewed and someone will figure out the procedure. label Sep 29, 2021
@ZakAyesh
Copy link

Thanks for making this issue. It is being investigated!

@archseer
Copy link
Contributor

Looks like this was fixed in 138c67e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating Needs someone to take a deeper look. Has been viewed and someone will figure out the procedure.
Projects
None yet
Development

No branches or pull requests

3 participants