Skip to content
Merged
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
42 changes: 42 additions & 0 deletions internal/server/difc_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,48 @@ func TestBuildDIFCFilteredNotice_ItemWithNoDescription(t *testing.T) {
assert.Contains(t, notice, "1 item(s)")
}

// TestBuildDIFCFilteredNotice_ItemWithDescOnly verifies that an item with a description
// but no reason is included in the inline notice using only the description.
func TestBuildDIFCFilteredNotice_ItemWithDescOnly(t *testing.T) {
f := &difc.FilteredCollectionLabeledData{
Filtered: []difc.FilteredItemDetail{
newTestFilteredItem(nil, "issue:org/repo#42", "", nil, nil),
},
TotalCount: 1,
}

notice := buildDIFCFilteredNotice(f)

assert.NotEmpty(t, notice)
assert.Contains(t, notice, "[Filtered]")
assert.Contains(t, notice, "1 item(s)")
assert.Contains(t, notice, "are not shown: issue:org/repo#42")
// Ensure the description is not formatted with a parenthesized reason.
assert.NotContains(t, notice, "issue:org/repo#42 (")
}

// TestBuildDIFCFilteredNotice_ItemWithReasonOnly verifies that an item with a reason
// but no description is included in the inline notice using only the reason.
func TestBuildDIFCFilteredNotice_ItemWithReasonOnly(t *testing.T) {
f := &difc.FilteredCollectionLabeledData{
Filtered: []difc.FilteredItemDetail{
{
Item: difc.LabeledItem{Data: "raw", Labels: difc.NewLabeledResource("")},
Reason: "integrity too low",
},
},
TotalCount: 1,
}

notice := buildDIFCFilteredNotice(f)

assert.NotEmpty(t, notice)
assert.Contains(t, notice, "[Filtered]")
assert.Contains(t, notice, "1 item(s)")
assert.Contains(t, notice, "are not shown: integrity too low")
assert.NotContains(t, notice, "raw")
}

// TestBuildDIFCFilteredNotice_SecrecyViolation verifies that secrecy-blocked items
// produce a notice that says "secrecy policy", not "integrity policy".
func TestBuildDIFCFilteredNotice_SecrecyViolation(t *testing.T) {
Expand Down
Loading