github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/examples/gno.land/r/x/nir1218_evaluation_proposal/evaluation_test.gno (about) 1 package evaluation 2 3 /* 4 1. At what stage of the PR a contribution should be evaluated? 5 Should the PR be approved first? 6 2. Can a contribution be re-evaluated before approved (current assumption is once a contribution is approved its state is final)? 7 3. Can an evaluation criteria change up until it is approved (current assumption is that the evaluation criteria is set when the contribution is added)? 8 */ 9 10 import ( 11 "std" 12 "testing" 13 14 "gno.land/p/demo/avl" 15 "gno.land/p/demo/testutils" 16 "gno.land/p/demo/ufmt" 17 ) 18 19 var ( 20 e = NewEvalutaion() 21 22 id = 792 23 name = "Evaluation DAO Kick Off" 24 description = "The PR is to initiate a discussion regarding the evaluation DAO" 25 status = "Draft" 26 category = "feat" 27 criteria = map[string]int32{"simplicity": 1, "usefullnes": 1, "quality": 1} 28 address = testutils.TestAddress("contributor") 29 ) 30 31 func TestEvaluationAddContribution(t *testing.T) { 32 pr := NewPullRequest(id, name, description, status, category) 33 contributionId, ok := e.AddContribution(pr, address) 34 35 t.Run("", func(t *testing.T) { 36 if contributionId != id { 37 t.Errorf("Got Contribution Id %d expected %d", contributionId, id) 38 } 39 }) 40 41 t.Run("Contribution added using the pull request id", func(t *testing.T) { 42 c, _ := e.contributions.Get(ufmt.Sprintf("%d", id)) 43 contribtution := c.(*Contribution) 44 if contribtution.Id() != id { 45 t.Errorf("Got Contribution Id %d expected %d", contribtution.Id(), id) 46 } 47 }) 48 49 t.Run("Pull Request added using the pull request id", func(t *testing.T) { 50 pr, _ := e.pullrequests.Get(ufmt.Sprintf("%d", id)) 51 pullrequest := pr.(*PullRequest) 52 if pullrequest.Id() != id { 53 t.Errorf("Got Pull Request Id %d expected %d", pullrequest.Id(), id) 54 } 55 }) 56 } 57 58 func TestEvaluationUpdateContribution(t *testing.T) { 59 t.Run("", func(t *testing.T) { 60 status := "Negotiated" 61 ok := e.UpdateContribution(id, status) 62 if !ok { 63 t.Error("Expected evaluation to update contribution's status successfully but failed") 64 } 65 }) 66 67 t.Run("Contribution doesn't exist", func(t *testing.T) { 68 id := 1 69 status := "Negotiated" 70 ok := e.UpdateContribution(id, status) 71 if ok { 72 t.Error("Expected evaluation to fail but pass") 73 } 74 }) 75 }