12345678910111213141516171819202122232425262728293031323334353637 |
- package integrationtests_test
- import (
- "strings"
- "testing"
- "github.com/langgenius/dify-sandbox/internal/core/runner/types"
- "github.com/langgenius/dify-sandbox/internal/service"
- )
- func TestNodejsRunCommand(t *testing.T) {
- // Test case for run_command
- resp := service.RunNodeJsCode(`
- const { spawn } = require( 'child_process' );
- const ls = spawn( 'ls', [ '-lh', '/usr' ] );
- ls.stdout.on( 'data', ( data ) => {
- console.log(data);
- } );
- ls.stderr.on( 'data', ( data ) => {
- console.log(data);
- } );
- ls.on( 'close', ( code ) => {
- console.log(code);
- } );
- `, "", &types.RunnerOptions{})
- if resp.Code != 0 {
- t.Error(resp)
- }
- if !strings.Contains(resp.Data.(*service.RunCodeResponse).Stderr, "operation not permitted") {
- t.Error(resp.Data.(*service.RunCodeResponse).Stderr)
- }
- }
|