github.com/TIBCOSoftware/flogo-lib@v0.5.9/engine/config_test.go (about)

     1  package engine
     2  
     3  import (
     4  	"os"
     5  	"strconv"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  )
    10  
    11  //TestNewPooledConfigOk
    12  func TestNewPooledConfigDefault(t *testing.T) {
    13  	pooledConfig := NewPooledRunnerConfig()
    14  
    15  	// assert Success
    16  	assert.Equal(t, RUNNER_WORKERS_DEFAULT, pooledConfig.NumWorkers)
    17  	assert.Equal(t, RUNNER_QUEUE_SIZE_DEFAULT, pooledConfig.WorkQueueSize)
    18  }
    19  
    20  //TestNewPooledConfigOk
    21  func TestNewPooledConfigOverride(t *testing.T) {
    22  	previousWorkers := os.Getenv(ENV_RUNNER_WORKERS_KEY)
    23  	defer os.Setenv(ENV_RUNNER_WORKERS_KEY, previousWorkers)
    24  	previousQueue := os.Getenv(ENV_RUNNER_QUEUE_SIZE_KEY)
    25  	defer os.Setenv(ENV_RUNNER_QUEUE_SIZE_KEY, previousQueue)
    26  
    27  	newWorkersValue := 6
    28  	newQueueValue := 60
    29  
    30  	// Change values
    31  	os.Setenv(ENV_RUNNER_WORKERS_KEY, strconv.Itoa(newWorkersValue))
    32  	os.Setenv(ENV_RUNNER_QUEUE_SIZE_KEY, strconv.Itoa(newQueueValue))
    33  
    34  	pooledConfig := NewPooledRunnerConfig()
    35  
    36  	// assert Success
    37  	assert.Equal(t, newWorkersValue, pooledConfig.NumWorkers)
    38  	assert.Equal(t, newQueueValue, pooledConfig.WorkQueueSize)
    39  }