mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-30 22:11:07 +00:00 
			
		
		
		
	- Massive replacement of changing `code.gitea.io/gitea` to `forgejo.org`. - Resolves forgejo/discussions#258 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7337 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Reviewed-by: Beowulf <beowulf@beocode.eu> Reviewed-by: Panagiotis "Ivory" Vasilopoulos <git@n0toose.net> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
		
			
				
	
	
		
			65 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2024 The Gitea Authors.
 | |
| // All rights reserved.
 | |
| // SPDX-License-Identifier: MIT
 | |
| 
 | |
| package pull
 | |
| 
 | |
| import (
 | |
| 	"testing"
 | |
| 
 | |
| 	git_model "forgejo.org/models/git"
 | |
| 	"forgejo.org/modules/structs"
 | |
| 
 | |
| 	"github.com/stretchr/testify/assert"
 | |
| )
 | |
| 
 | |
| func TestMergeRequiredContextsCommitStatus(t *testing.T) {
 | |
| 	testCases := [][]*git_model.CommitStatus{
 | |
| 		{
 | |
| 			{Context: "Build 1", State: structs.CommitStatusSuccess},
 | |
| 			{Context: "Build 2", State: structs.CommitStatusSuccess},
 | |
| 			{Context: "Build 3", State: structs.CommitStatusSuccess},
 | |
| 		},
 | |
| 		{
 | |
| 			{Context: "Build 1", State: structs.CommitStatusSuccess},
 | |
| 			{Context: "Build 2", State: structs.CommitStatusSuccess},
 | |
| 			{Context: "Build 2t", State: structs.CommitStatusPending},
 | |
| 		},
 | |
| 		{
 | |
| 			{Context: "Build 1", State: structs.CommitStatusSuccess},
 | |
| 			{Context: "Build 2", State: structs.CommitStatusSuccess},
 | |
| 			{Context: "Build 2t", State: structs.CommitStatusFailure},
 | |
| 		},
 | |
| 		{
 | |
| 			{Context: "Build 1", State: structs.CommitStatusSuccess},
 | |
| 			{Context: "Build 2", State: structs.CommitStatusSuccess},
 | |
| 			{Context: "Build 2t", State: structs.CommitStatusSuccess},
 | |
| 		},
 | |
| 		{
 | |
| 			{Context: "Build 1", State: structs.CommitStatusSuccess},
 | |
| 			{Context: "Build 2", State: structs.CommitStatusSuccess},
 | |
| 			{Context: "Build 2t", State: structs.CommitStatusSuccess},
 | |
| 		},
 | |
| 	}
 | |
| 	testCasesRequiredContexts := [][]string{
 | |
| 		{"Build*"},
 | |
| 		{"Build*", "Build 2t*"},
 | |
| 		{"Build*", "Build 2t*"},
 | |
| 		{"Build*", "Build 2t*", "Build 3*"},
 | |
| 		{"Build*", "Build *", "Build 2t*", "Build 1*"},
 | |
| 	}
 | |
| 
 | |
| 	testCasesExpected := []structs.CommitStatusState{
 | |
| 		structs.CommitStatusSuccess,
 | |
| 		structs.CommitStatusPending,
 | |
| 		structs.CommitStatusFailure,
 | |
| 		structs.CommitStatusPending,
 | |
| 		structs.CommitStatusSuccess,
 | |
| 	}
 | |
| 
 | |
| 	for i, commitStatuses := range testCases {
 | |
| 		if MergeRequiredContextsCommitStatus(commitStatuses, testCasesRequiredContexts[i]) != testCasesExpected[i] {
 | |
| 			assert.Fail(t, "Test case failed", "Test case %d failed", i+1)
 | |
| 		}
 | |
| 	}
 | |
| }
 |