gitlab.com/evatix-go/core@v1.3.55/tests/integratedtests/chmodhelpertests/RwxWrapperManyApplyValue_test.go (about)

     1  package chmodhelpertests
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"gitlab.com/evatix-go/core/chmodhelper"
     8  	"gitlab.com/evatix-go/core/chmodhelper/chmodins"
     9  	"gitlab.com/evatix-go/core/coretests"
    10  	"gitlab.com/evatix-go/core/errcore"
    11  	"gitlab.com/evatix-go/core/tests/testwrappers/chmodhelpertestwrappers"
    12  )
    13  
    14  // Test_RwxWrapperManyApplyValue_Unix
    15  //
    16  //  for directory `-` will be placed not `d`
    17  func Test_RwxWrapperManyApplyValue_Unix(t *testing.T) {
    18  	coretests.SkipOnWindows(t)
    19  
    20  	// Arrange
    21  	createPathInstructions := chmodhelpertestwrappers.CreatePathInstruction2
    22  	chmodhelper.CreateDirFilesWithRwxPermissionsMust(
    23  		true,
    24  		&createPathInstructions)
    25  	firstCreationIns := createPathInstructions[0]
    26  	paths := firstCreationIns.GetPaths()
    27  	condition := chmodins.DefaultAllTrueCondition()
    28  	existingAppliedRwxFull := firstCreationIns.ApplyRwx.String()
    29  	for _, testCase := range chmodhelpertestwrappers.SingleRwxTestCases {
    30  		rwxWrapper, err := testCase.ToDisabledRwxWrapper()
    31  		errcore.SimpleHandleErr(err, "SingleRwx ToDisabledRwxWrapper failed")
    32  		expectation := rwxWrapper.ToFullRwxValueString()
    33  
    34  		header := fmt.Sprintf(
    35  			"Existing [%s] Applied by [%s] should result [%s]",
    36  			existingAppliedRwxFull,
    37  			expectation,
    38  			expectation)
    39  
    40  		// Act
    41  		err2 := rwxWrapper.ApplyLinuxChmodOnMany(condition, paths...)
    42  		errcore.SimpleHandleErr(
    43  			err2,
    44  			"rwxWrapper.ApplyLinuxChmodOnMany failed")
    45  
    46  		// Assert
    47  		assertSingleChmod(
    48  			t,
    49  			header,
    50  			firstCreationIns,
    51  			expectation)
    52  	}
    53  }