github.com/matrixorigin/matrixone@v0.7.0/pkg/sql/colexec/table_function/table_function_test.go (about)

     1  // Copyright 2022 Matrix Origin
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package table_function
    16  
    17  import (
    18  	"bytes"
    19  	"testing"
    20  
    21  	"github.com/matrixorigin/matrixone/pkg/testutil"
    22  	"github.com/stretchr/testify/require"
    23  )
    24  
    25  func TestString(t *testing.T) {
    26  	arg := Argument{Name: "unnest"}
    27  	String(&arg, bytes.NewBuffer(nil))
    28  }
    29  
    30  func TestCall(t *testing.T) {
    31  	arg := Argument{Name: "unnest"}
    32  	end, err := Call(0, testutil.NewProc(), &arg, false, false)
    33  	require.NoError(t, err)
    34  	require.True(t, end)
    35  	arg.Name = "generate_series"
    36  	end, err = Call(0, testutil.NewProc(), &arg, false, false)
    37  	require.NoError(t, err)
    38  	require.True(t, end)
    39  	arg.Name = "not_exist"
    40  	end, err = Call(0, testutil.NewProc(), &arg, false, false)
    41  	require.Error(t, err)
    42  	require.True(t, end)
    43  }
    44  
    45  func TestPrepare(t *testing.T) {
    46  	arg := Argument{Name: "unnest"}
    47  	err := Prepare(testutil.NewProc(), &arg)
    48  	require.Error(t, err)
    49  	arg.Name = "generate_series"
    50  	err = Prepare(testutil.NewProc(), &arg)
    51  	require.NoError(t, err)
    52  	arg.Name = "not_exist"
    53  	err = Prepare(testutil.NewProc(), &arg)
    54  	require.Error(t, err)
    55  }