Skip to content

add a few no-file tests#53

Merged
onyxraven merged 2 commits intomasterfrom
git-scm-tests
Oct 3, 2022
Merged

add a few no-file tests#53
onyxraven merged 2 commits intomasterfrom
git-scm-tests

Conversation

@onyxraven
Copy link
Member

@onyxraven onyxraven commented Sep 28, 2022

Background

Adds a few 'no gitignore' tests. Followup of #50

Also prefers to add a newline at the end of the gitignore.

Versioning

batched up in the next release

Tasks

  • Specs written
  • Manual testing

/cc

@randrusiak

@onyxraven onyxraven self-assigned this Sep 28, 2022
}

if _, err := file.WriteString(line); err != nil {
if _, err := file.WriteString(line + "\n"); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefers adding the newline.

t.Run("missing gitignore file", func(t *testing.T) {
tempFilePath := t.TempDir() + "/.gitignore"
if _, err := os.Stat(tempFilePath); err == nil {
t.Errorf("RemoveFileFromIgnored() = gitignore accidentally exists")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specifically test that we're not using some leftover from another test

}

if _, err := os.Stat(tempFilePath); err == nil {
t.Errorf("RemoveFileFromIgnored() = gitignore exists when it should not")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensure we didn't accidentally do something to the file (which still shouldn't exist)

t.Run(tt.name, func(t *testing.T) {
tempFilePath := t.TempDir() + "/.gitignore"
err := os.WriteFile(tempFilePath, tt.gitIgnoreContent, 0644)
err := os.WriteFile(tempFilePath, tt.gitIgnoreContent, 0600)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linter wanted this, and in a test, this makes sense

Copy link

@dennis-johnson-dev dennis-johnson-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

}
}

func TestAddFileNoExistingFile(t *testing.T) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the test 👍

@onyxraven onyxraven merged commit e2ddb0b into master Oct 3, 2022
@onyxraven onyxraven deleted the git-scm-tests branch October 3, 2022 19:37
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

Successfully merging this pull request may close these issues.

3 participants