mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Refactor older tests to use testify (#33140)
Refactor checks to use assert/require Use require.Eventually for waiting in elastic and meilisearch tests Use require to exit early instead of assert
This commit is contained in:
		| @@ -9,6 +9,8 @@ import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"code.gitea.io/gitea/modules/setting" | ||||
|  | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| ) | ||||
|  | ||||
| func Test_isGitRawOrLFSPath(t *testing.T) { | ||||
| @@ -108,26 +110,22 @@ func Test_isGitRawOrLFSPath(t *testing.T) { | ||||
| 		t.Run(tt.path, func(t *testing.T) { | ||||
| 			req, _ := http.NewRequest("POST", "http://localhost"+tt.path, nil) | ||||
| 			setting.LFS.StartServer = false | ||||
| 			if got := isGitRawOrAttachOrLFSPath(req); got != tt.want { | ||||
| 				t.Errorf("isGitOrLFSPath() = %v, want %v", got, tt.want) | ||||
| 			} | ||||
| 			assert.Equal(t, tt.want, isGitRawOrAttachOrLFSPath(req)) | ||||
|  | ||||
| 			setting.LFS.StartServer = true | ||||
| 			if got := isGitRawOrAttachOrLFSPath(req); got != tt.want { | ||||
| 				t.Errorf("isGitOrLFSPath() = %v, want %v", got, tt.want) | ||||
| 			} | ||||
| 			assert.Equal(t, tt.want, isGitRawOrAttachOrLFSPath(req)) | ||||
| 		}) | ||||
| 	} | ||||
| 	for _, tt := range lfsTests { | ||||
| 		t.Run(tt, func(t *testing.T) { | ||||
| 			req, _ := http.NewRequest("POST", tt, nil) | ||||
| 			setting.LFS.StartServer = false | ||||
| 			if got := isGitRawOrAttachOrLFSPath(req); got != setting.LFS.StartServer { | ||||
| 				t.Errorf("isGitOrLFSPath(%q) = %v, want %v, %v", tt, got, setting.LFS.StartServer, gitRawOrAttachPathRe.MatchString(tt)) | ||||
| 			} | ||||
| 			got := isGitRawOrAttachOrLFSPath(req) | ||||
| 			assert.Equalf(t, setting.LFS.StartServer, got, "isGitOrLFSPath(%q) = %v, want %v, %v", tt, got, setting.LFS.StartServer, gitRawOrAttachPathRe.MatchString(tt)) | ||||
|  | ||||
| 			setting.LFS.StartServer = true | ||||
| 			if got := isGitRawOrAttachOrLFSPath(req); got != setting.LFS.StartServer { | ||||
| 				t.Errorf("isGitOrLFSPath(%q) = %v, want %v", tt, got, setting.LFS.StartServer) | ||||
| 			} | ||||
| 			got = isGitRawOrAttachOrLFSPath(req) | ||||
| 			assert.Equalf(t, setting.LFS.StartServer, got, "isGitOrLFSPath(%q) = %v, want %v", tt, got, setting.LFS.StartServer) | ||||
| 		}) | ||||
| 	} | ||||
| 	setting.LFS.StartServer = origLFSStartServer | ||||
|   | ||||
		Reference in New Issue
	
	Block a user