mirror of
				https://github.com/gin-gonic/gin.git
				synced 2025-11-04 17:22:12 +08:00 
			
		
		
		
	fix(test): only check Location header (#1064)
* fix(test): only check Location header * fix(test): rename field * fix(test): not export field
This commit is contained in:
		
							parent
							
								
									81007d2ce0
								
							
						
					
					
						commit
						4b5ec517da
					
				@ -358,23 +358,23 @@ func TestRouterNotFound(t *testing.T) {
 | 
				
			|||||||
	testRoutes := []struct {
 | 
						testRoutes := []struct {
 | 
				
			||||||
		route    string
 | 
							route    string
 | 
				
			||||||
		code     int
 | 
							code     int
 | 
				
			||||||
		header string
 | 
							location string
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{"/path/", 301, "map[Location:[/path]]"},   // TSR -/
 | 
							{"/path/", 301, "/path"},   // TSR -/
 | 
				
			||||||
		{"/dir", 301, "map[Location:[/dir/]]"},     // TSR +/
 | 
							{"/dir", 301, "/dir/"},     // TSR +/
 | 
				
			||||||
		{"", 301, "map[Location:[/]]"},             // TSR +/
 | 
							{"", 301, "/"},             // TSR +/
 | 
				
			||||||
		{"/PATH", 301, "map[Location:[/path]]"},    // Fixed Case
 | 
							{"/PATH", 301, "/path"},    // Fixed Case
 | 
				
			||||||
		{"/DIR/", 301, "map[Location:[/dir/]]"},    // Fixed Case
 | 
							{"/DIR/", 301, "/dir/"},    // Fixed Case
 | 
				
			||||||
		{"/PATH/", 301, "map[Location:[/path]]"},   // Fixed Case -/
 | 
							{"/PATH/", 301, "/path"},   // Fixed Case -/
 | 
				
			||||||
		{"/DIR", 301, "map[Location:[/dir/]]"},     // Fixed Case +/
 | 
							{"/DIR", 301, "/dir/"},     // Fixed Case +/
 | 
				
			||||||
		{"/../path", 301, "map[Location:[/path]]"}, // CleanPath
 | 
							{"/../path", 301, "/path"}, // CleanPath
 | 
				
			||||||
		{"/nope", 404, ""},         // NotFound
 | 
							{"/nope", 404, ""},         // NotFound
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for _, tr := range testRoutes {
 | 
						for _, tr := range testRoutes {
 | 
				
			||||||
		w := performRequest(router, "GET", tr.route)
 | 
							w := performRequest(router, "GET", tr.route)
 | 
				
			||||||
		assert.Equal(t, w.Code, tr.code)
 | 
							assert.Equal(t, w.Code, tr.code)
 | 
				
			||||||
		if w.Code != 404 {
 | 
							if w.Code != 404 {
 | 
				
			||||||
			assert.Equal(t, fmt.Sprint(w.Header()), tr.header)
 | 
								assert.Equal(t, fmt.Sprint(w.Header().Get("Location")), tr.location)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user