pkg.tk-software.de/gotice@v0.4.1-0.20240224130243-6adec687b106/main_test.go (about)

     1  // Copyright 2023-2024 Tobias Koch. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"errors"
     9  	"testing"
    10  )
    11  
    12  func TestExec(t *testing.T) {
    13  	args := []string{
    14  		"param0",
    15  		"version",
    16  	}
    17  
    18  	if err := exec(args); err != nil {
    19  		t.Errorf("Expected no error, got %s", err)
    20  	}
    21  }
    22  
    23  func TestExecNoSubcommand(t *testing.T) {
    24  	args := []string{
    25  		"param0",
    26  	}
    27  
    28  	if err := exec(args); !errors.Is(err, ErrMissingSubcommand) {
    29  		t.Errorf("Expected error %s, got %s", ErrMissingSubcommand, err)
    30  	}
    31  }
    32  
    33  func TestExecUnknownSubcommand(t *testing.T) {
    34  	args := []string{
    35  		"param0",
    36  		"unknown-command",
    37  	}
    38  
    39  	if err := exec(args); err == nil {
    40  		t.Errorf("Expected error, got none")
    41  	}
    42  }