github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/sys/it/impl_renameqname_test.go (about)

     1  /*
     2   * Copyright (c) 2023-present unTill Pro, Ltd.
     3   */
     4  
     5  package sys_it
     6  
     7  import (
     8  	"testing"
     9  
    10  	"github.com/voedger/voedger/pkg/istructs"
    11  	it "github.com/voedger/voedger/pkg/vit"
    12  )
    13  
    14  func TestBasicUsage_RenameQName(t *testing.T) {
    15  	vit := it.NewVIT(t, &it.SharedConfig_App1)
    16  	defer vit.TearDown()
    17  
    18  	ws := vit.WS(istructs.AppQName_test1_app1, "test_ws")
    19  	// ensure untill.category is not renamed yet
    20  	body := `{"cuds":[{"fields":{"sys.ID":1,"sys.QName":"app1pkg.category","name":"Awesome food"}}]}`
    21  	vit.PostWS(ws, "c.sys.CUD", body)
    22  
    23  	bodyRename := `{"args":{"ExistingQName":"app1pkg.category","NewQName":"app1pkg.categorynew"}}`
    24  	vit.PostWS(ws, "c.sys.RenameQName", bodyRename)
    25  
    26  	// need to restart the server
    27  	// body = `{"cuds":[{"fields":{"sys.ID":1,"sys.QName":"app1pkg.categorynew","name":"Awesome food"}}]}`
    28  	// vit.PostWS(ws, "c.sys.CUD", body)
    29  
    30  	// hit.PostApp(istructs.AppQName_test1_app1, ws.Owner.PseudoProfileWSID, "c.sys.RenameQName", body, utils.WithAuthorizeBy(sysToken))
    31  
    32  	// // ensure c.sys.CUD is not renamed yet
    33  	// body := `{"cuds":[{"fields":{"sys.ID":1,"sys.QName":"untill.category","name":"Awesome food"}}]}`
    34  	// hit.PostWS(ws, "c.sys.CUDnew", body, utils.Expect400())
    35  
    36  	// sysToken, err := payloads.GetSystemPrincipalToken(hit.ITokens, istructs.AppQName_test1_app1)
    37  	// require.NoError(t, err)
    38  	// hit.PostApp(istructs.AppQName_test1_app1, ws.Owner.PseudoProfileWSID, "c.sys.CUD", body, utils.WithAuthorizeBy(sysToken))
    39  
    40  	// // rename command
    41  	// // body = `{"args":{"ExistingQName":"sys.CUD","NewQName":"sys.CUDnew"}}`
    42  	// body = `{"args":{"ExistingQName":"untill.category","NewQName":"untill.categorynew"}}`
    43  	// hit.PostApp(istructs.AppQName_test1_app1, ws.Owner.PseudoProfileWSID, "c.sys.RenameQName", body, utils.WithAuthorizeBy(sysToken))
    44  
    45  	// // try to call the command by the new QName
    46  	// body = `{"cuds":[{"fields":{"sys.ID":1,"sys.QName":"untill.categorynew","name":"Awesome food"}}]}`
    47  	// hit.PostWS(ws, "c.sys.CUD", body)
    48  }