github.com/psiphon-labs/goarista@v0.0.0-20160825065156-d002785f4c67/test/fileutil.go (about)

     1  // Copyright (C) 2015  Arista Networks, Inc.
     2  // Use of this source code is governed by the Apache License 2.0
     3  // that can be found in the COPYING file.
     4  
     5  package test
     6  
     7  import (
     8  	"io"
     9  	"os"
    10  	"testing"
    11  )
    12  
    13  // CopyFile copies a file
    14  func CopyFile(t *testing.T, srcPath, dstPath string) {
    15  	src, err := os.Open(srcPath)
    16  	if err != nil {
    17  		t.Fatal(err)
    18  	}
    19  	defer src.Close()
    20  	dst, err := os.Create(dstPath)
    21  	if err != nil {
    22  		t.Fatal(err)
    23  	}
    24  	defer dst.Close()
    25  	_, err = io.Copy(dst, src)
    26  	if err != nil {
    27  		t.Fatal(err)
    28  	}
    29  }