code.vegaprotocol.io/vega@v0.79.0/datanode/entities/proposal_test.go (about)

     1  // Copyright (C) 2023 Gobalsky Labs Limited
     2  //
     3  // This program is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU Affero General Public License as
     5  // published by the Free Software Foundation, either version 3 of the
     6  // License, or (at your option) any later version.
     7  //
     8  // This program is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  // GNU Affero General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU Affero General Public License
    14  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15  
    16  package entities
    17  
    18  import (
    19  	"testing"
    20  
    21  	v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2"
    22  
    23  	"github.com/stretchr/testify/assert"
    24  )
    25  
    26  func TestProposalType_String(t *testing.T) {
    27  	tests := []struct {
    28  		name string
    29  		pt   *v2.ListGovernanceDataRequest_Type
    30  		want string
    31  	}{
    32  		{
    33  			name: "ProposalTypeNewMarket",
    34  			pt:   toPtr(v2.ListGovernanceDataRequest_TYPE_NEW_MARKET),
    35  			want: "newMarket",
    36  		}, {
    37  			name: "ProposalTypeNewAsset",
    38  			pt:   toPtr(v2.ListGovernanceDataRequest_TYPE_NEW_ASSET),
    39  			want: "newAsset",
    40  		}, {
    41  			name: "ProposalTypeUpdateAsset",
    42  			pt:   toPtr(v2.ListGovernanceDataRequest_TYPE_UPDATE_ASSET),
    43  			want: "updateAsset",
    44  		}, {
    45  			name: "ProposalTypeUpdateMarket",
    46  			pt:   toPtr(v2.ListGovernanceDataRequest_TYPE_UPDATE_MARKET),
    47  			want: "updateMarket",
    48  		}, {
    49  			name: "ProposalTypeUpdateNetworkParameter",
    50  			pt:   toPtr(v2.ListGovernanceDataRequest_TYPE_NETWORK_PARAMETERS),
    51  			want: "updateNetworkParameter",
    52  		}, {
    53  			name: "ProposalTypeNewFreeform",
    54  			pt:   toPtr(v2.ListGovernanceDataRequest_TYPE_NEW_FREE_FORM),
    55  			want: "newFreeform",
    56  		}, {
    57  			name: "unknown",
    58  			pt:   toPtr(v2.ListGovernanceDataRequest_Type(100)),
    59  			want: "unknown",
    60  		}, {
    61  			name: "nil",
    62  			pt:   nil,
    63  			want: "",
    64  		},
    65  	}
    66  	for _, tt := range tests {
    67  		t.Run(tt.name, func(t *testing.T) {
    68  			assert.Equalf(t, tt.want, (*ProposalType)(tt.pt).String(), "String()")
    69  		})
    70  	}
    71  }