github.com/codingfuture/orig-energi3@v0.8.4/cmd/swarm/global-store/run_test.go (about)

     1  // Copyright 2019 The Energi Core Authors
     2  // Copyright 2018 The go-ethereum Authors
     3  // This file is part of Energi Core.
     4  //
     5  // Energi Core is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU General Public License as published by
     7  // the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  //
    10  // Energi Core is distributed in the hope that it will be useful,
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  // GNU General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU General Public License
    16  // along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
    17  
    18  package main
    19  
    20  import (
    21  	"fmt"
    22  	"os"
    23  	"testing"
    24  
    25  	"github.com/docker/docker/pkg/reexec"
    26  	"github.com/ethereum/go-ethereum/internal/cmdtest"
    27  )
    28  
    29  func init() {
    30  	reexec.Register("swarm-global-store", func() {
    31  		if err := newApp().Run(os.Args); err != nil {
    32  			fmt.Fprintln(os.Stderr, err)
    33  			os.Exit(1)
    34  		}
    35  		os.Exit(0)
    36  	})
    37  }
    38  
    39  func runGlobalStore(t *testing.T, args ...string) *cmdtest.TestCmd {
    40  	tt := cmdtest.NewTestCmd(t, nil)
    41  	tt.Run("swarm-global-store", args...)
    42  	return tt
    43  }
    44  
    45  func TestMain(m *testing.M) {
    46  	if reexec.Init() {
    47  		return
    48  	}
    49  	os.Exit(m.Run())
    50  }