(t *testing.T)
| 664 | } |
| 665 | |
| 666 | func TestExtractKey(t *testing.T) { |
| 667 | tests := []struct { |
| 668 | name string |
| 669 | header string |
| 670 | expected string |
| 671 | }{ |
| 672 | { |
| 673 | name: "Valid key", |
| 674 | header: "test-key", |
| 675 | expected: "test-key", |
| 676 | }, |
| 677 | { |
| 678 | name: "Empty key", |
| 679 | header: "", |
| 680 | expected: "", |
| 681 | }, |
| 682 | } |
| 683 | |
| 684 | for _, tt := range tests { |
| 685 | t.Run(tt.name, func(t *testing.T) { |
| 686 | c, _ := gin.CreateTestContext(httptest.NewRecorder()) |
| 687 | c.Request = httptest.NewRequest("GET", "/", nil) |
| 688 | if tt.header != "" { |
| 689 | c.Request.Header.Set(KeyHeader, tt.header) |
| 690 | } |
| 691 | |
| 692 | result := extractKey(c) |
| 693 | assert.Equal(t, tt.expected, result) |
| 694 | }) |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | func TestHasPermission(t *testing.T) { |
| 699 | tests := []struct { |
nothing calls this directly
no test coverage detected