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

Gisty.Comments should not implement dummy data #4

Open
KEINOS opened this issue May 30, 2023 · 1 comment
Open

Gisty.Comments should not implement dummy data #4

KEINOS opened this issue May 30, 2023 · 1 comment

Comments

@KEINOS
Copy link
Owner

KEINOS commented May 30, 2023

Currently Gisty.Comments returns a dummy data if the requested gist ID is equal to gist.DummyID.

func (g *Gisty) Comments(gistID string) ([]Comment, error) {
// Return dummy data if the gist ID is the dummy ID to avoid unwanted request
// in the example of the test.
if gistID == DummyID {
return []Comment{DummyComment}, nil
}
return g.comments(gistID, g.AltFunctions.Comments)
}

But it should use the Gisty.AltFunctions to mock the behavior like the others.

obj.AltFunctions.List = func(*list.ListOptions) error {
// Mock the GitHub API response.
fmt.Fprint(
obj.Stdout,
"d5b9800c636dd78defa4f15894d54d29 Title of gist item2 6 files secret 2022-04-16T06:08:46Z",
)
return nil
}

@KEINOS
Copy link
Owner Author

KEINOS commented May 31, 2023

The current behavior of Gisty.Comments is due to simplify the use in the examples.
Writing a mock in the example is bit redundant.

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

1 participant