github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/token_nft_allowance_unit_test.go (about) 1 //go:build all || unit 2 // +build all unit 3 4 package hedera 5 6 /*- 7 * 8 * Hedera Go SDK 9 * 10 * Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC 11 * 12 * Licensed under the Apache License, Version 2.0 (the "License"); 13 * you may not use this file except in compliance with the License. 14 * You may obtain a copy of the License at 15 * 16 * http://www.apache.org/licenses/LICENSE-2.0 17 * 18 * Unless required by applicable law or agreed to in writing, software 19 * distributed under the License is distributed on an "AS IS" BASIS, 20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 * See the License for the specific language governing permissions and 22 * limitations under the License. 23 * 24 */ 25 26 import ( 27 "testing" 28 29 "github.com/stretchr/testify/assert" 30 ) 31 32 func TestUnitNewTokenNftAllowance(t *testing.T) { 33 tokenID := TokenID{Token: 1} 34 owner := AccountID{Account: 2} 35 spender := AccountID{Account: 3} 36 serialNumbers := []int64{1, 2, 3} 37 approvedForAll := true 38 delegatingSpender := AccountID{Account: 4} 39 40 allowance := NewTokenNftAllowance(tokenID, owner, spender, serialNumbers, approvedForAll, delegatingSpender) 41 42 assert.Equal(t, &tokenID, allowance.TokenID) 43 assert.Equal(t, &owner, allowance.OwnerAccountID) 44 assert.Equal(t, &spender, allowance.SpenderAccountID) 45 assert.Equal(t, serialNumbers, allowance.SerialNumbers) 46 assert.Equal(t, approvedForAll, allowance.AllSerials) 47 assert.Equal(t, &delegatingSpender, allowance.DelegatingSpender) 48 } 49 50 func TestUnitTokenNftAllowance_String(t *testing.T) { 51 approval := TokenNftAllowance{ 52 TokenID: &TokenID{Token: 1}, 53 SpenderAccountID: &AccountID{Account: 2}, 54 OwnerAccountID: &AccountID{Account: 3}, 55 SerialNumbers: []int64{1, 2, 3}, 56 AllSerials: true, 57 DelegatingSpender: &AccountID{Account: 4}, 58 } 59 60 assert.Equal(t, "OwnerAccountID: 0.0.3, SpenderAccountID: 0.0.2, TokenID: 0.0.1, Serials: 1, 2, 3, , ApprovedForAll: true", approval.String()) 61 }