Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cmd/dev/headers/comments/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestFileContentWithoutHeader(t *testing.T) {
t.Run("known file, copyright header", func(t *testing.T) {
t.Run("known file, copyright header, empty line", func(t *testing.T) {
give := "// Copyright © 2021 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nfile content"
want := "file content"
createTestFile(t, "testfile.go", give)
Expand All @@ -20,6 +20,16 @@ func TestFileContentWithoutHeader(t *testing.T) {
assert.Equal(t, want, have)
})

t.Run("known file, copyright header, no empty line", func(t *testing.T) {
give := "// Copyright © 2021 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\nfile content"
want := "file content"
createTestFile(t, "testfile.go", give)
defer os.Remove("testfile.go")
have, err := comments.FileContentWithoutHeader("testfile.go", "Copyright ©")
assert.NoError(t, err)
assert.Equal(t, want, have)
})

t.Run("known file, other comment first", func(t *testing.T) {
give := "// another comment block\n\n// Copyright © 2021 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nfile content"
want := "// another comment block\n\nfile content"
Expand Down
1 change: 0 additions & 1 deletion cmd/dev/headers/comments/formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func (f Format) remove(text string, token string) string {
}
if inComment && !strings.HasPrefix(line, f.startToken) {
inComment = false
continue
}
if !inComment {
result = append(result, line)
Expand Down