/*
Copyright 2019 The Skaffold Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package app

import (
	"bytes"
	"os"
	"testing"

	"github.com/GoogleContainerTools/skaffold/testutil"
)

func TestMain(t *testing.T) {
	var (
		output    bytes.Buffer
		errOutput bytes.Buffer
	)

	defer func(args []string) { os.Args = args }(os.Args)
	os.Args = []string{"skaffold", "help"}

	err := Run(&output, &errOutput)

	testutil.CheckError(t, false, err)
	testutil.CheckContains(t, "Available Commands", output.String())
	testutil.CheckDeepEqual(t, "", errOutput.String())
}

/*
Copyright 2019 The Skaffold Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package app

import (
	"bytes"
	"io/ioutil"
	"os"
	"testing"

	"github.com/GoogleContainerTools/skaffold/testutil"
)

func TestMainHelp(t *testing.T) {
	var (
		output    bytes.Buffer
		errOutput bytes.Buffer
	)

	defer func(args []string) { os.Args = args }(os.Args)
	os.Args = []string{"skaffold", "help"}

	err := Run(&output, &errOutput)

	testutil.CheckError(t, false, err)
	testutil.CheckContains(t, "Available Commands", output.String())
	testutil.CheckDeepEqual(t, "", errOutput.String())
}

func TestMainUnknownCommand(t *testing.T) {
	defer func(args []string) { os.Args = args }(os.Args)
	os.Args = []string{"skaffold", "unknown"}

	err := Run(ioutil.Discard, ioutil.Discard)

	testutil.CheckError(t, true, err)
}

Add test for unknown command
Add test for unknown command

Signed-off-by: David Gageot <aa743a0aaec8f7d7a1f01442503957f4d7a2d634@gageot.net>
