Skip to content
Snippets Groups Projects
Select Git revision
  • cb1f0038b696c9862ca83acc013aa394a7970657
  • master default protected
  • v1.22.9
  • v1.22.8
  • v1.22.7
  • v1.22.6
  • v1.22.5
  • v1.22.4
  • v1.22.3
  • v1.22.1
  • v1.22.0
  • v1.21.0
  • v1.20.5
  • v1.20.4
  • v1.20.3
  • v1.20.2
  • v1.20.1
  • v1.20.0
  • v1.19.0
  • v1.18.3
  • v1.18.2
  • v1.18.1
22 results

copyable_test.go

Blame
  • flag_test.go 935 B
    // Copyright 2022 schukai GmbH
    // SPDX-License-Identifier: AGPL-3.0-or-later
    
    package xflags
    
    import (
    	"fmt"
    	"github.com/stretchr/testify/assert"
    	"testing"
    )
    
    func TestWrongDefinitionType(t *testing.T) {
    	c := New("root", 2)
    	c.Parse([]string{"test"})
    	c.Execute()
    	assert.True(t, c.HasErrors())
    }
    
    type testExecuteCommandStruct struct {
    	Command1 struct {
    	} `command:"command1" description:"Command 1" callback:"command1Callback" `
    	Command2 struct {
    		Command3 struct {
    		} `command:"command3" description:"Command 3" callback:"command3Callback" `
    	} `command:"command2" description:"Command 2" callback:"command2Callback" `
    }
    
    func (c *testExecuteCommandStruct) command1Callback(args []string) {
    	fmt.Println("command1Callback", args)
    }
    
    func TestExecute1(t *testing.T) {
    	c := New("root", testExecuteCommandStruct{})
    	c.Parse([]string{"root", "command2", "command3", "commandX"})
    	c.Execute()
    	assert.False(t, c.HasErrors())
    }