| 101 | } |
| 102 | |
| 103 | func TestGetHeader(t *testing.T) { |
| 104 | tests := []struct { |
| 105 | name string |
| 106 | meta *model.Meta |
| 107 | path string |
| 108 | want string |
| 109 | reason string |
| 110 | }{ |
| 111 | { |
| 112 | name: "nil meta", |
| 113 | meta: nil, |
| 114 | path: "/any", |
| 115 | want: "", |
| 116 | reason: "nil meta should return empty", |
| 117 | }, |
| 118 | { |
| 119 | name: "exact path match with HeaderSub=false", |
| 120 | meta: &model.Meta{ |
| 121 | Path: "/folder", |
| 122 | Header: "Custom Header", |
| 123 | HeaderSub: false, |
| 124 | }, |
| 125 | path: "/folder", |
| 126 | want: "Custom Header", |
| 127 | reason: "exact path should show header", |
| 128 | }, |
| 129 | { |
| 130 | name: "sub path with HeaderSub=true", |
| 131 | meta: &model.Meta{ |
| 132 | Path: "/folder", |
| 133 | Header: "Custom Header", |
| 134 | HeaderSub: true, |
| 135 | }, |
| 136 | path: "/folder/subfolder", |
| 137 | want: "Custom Header", |
| 138 | reason: "sub path with HeaderSub=true should show header", |
| 139 | }, |
| 140 | { |
| 141 | name: "sub path with HeaderSub=false", |
| 142 | meta: &model.Meta{ |
| 143 | Path: "/folder", |
| 144 | Header: "Custom Header", |
| 145 | HeaderSub: false, |
| 146 | }, |
| 147 | path: "/folder/subfolder", |
| 148 | want: "", |
| 149 | reason: "sub path with HeaderSub=false should not show header", |
| 150 | }, |
| 151 | { |
| 152 | name: "non-sub path with HeaderSub=true (BEHAVIOR CHANGE - BUG FIX)", |
| 153 | meta: &model.Meta{ |
| 154 | Path: "/folder", |
| 155 | Header: "Custom Header", |
| 156 | HeaderSub: true, |
| 157 | }, |
| 158 | path: "/other", |
| 159 | want: "", |
| 160 | reason: "non-sub path should not show header even with HeaderSub=true (fixed bug)", |