// TestCopyDeep asserts that Copy correctly copies files at several levels of
// depth
TestCopyDeep asserts that Copy correctly copies files at several levels of
depth
// TestCopyDeep asserts that Copy correctly copies files at several levels of // depth
func TestCopyDeep(t *testing.T) {
	text := "this is the cheatsheet text"
	src, err := ioutil.TempFile("", "foo-src")
	if err != nil {
		t.Errorf("failed to mock cheatsheet: %v", err)
	}
	defer src.Close()
	defer os.Remove(src.Name())
	if _, err := src.WriteString(text); err != nil {
		t.Errorf("failed to write to mock cheatsheet: %v", err)
	}
	sheet, err := New(
		"/cheat-tests/alpha/bravo/foo",
		"community",
		src.Name(),
		[]string{},
		false,
	)
	if err != nil {
		t.Errorf("failed to init cheatsheet: %v", err)
	}
	outpath := path.Join(os.TempDir(), sheet.Title)
	defer os.RemoveAll(path.Join(os.TempDir(), "cheat-tests"))
	err = sheet.Copy(outpath)
	if err != nil {
		t.Errorf("failed to copy cheatsheet: %v", err)
	}
	got, err := ioutil.ReadFile(outpath)
	if err != nil {
		t.Errorf("failed to read destination file: %v", err)
	}
	if string(got) != text {
		t.Errorf(
			"destination file contained wrong text: want: '%s', got: '%s'",
			text,
			got,
		)
	}
}
func TestCopyDeep ( t * testing . T ) { text := " " src , err := ioutil . TempFile ( " " , " " ) if err != nil { t . Errorf ( " " , err ) } defer src . Close ( ) defer os . Remove ( src . Name ( ) ) if _ , err := src . WriteString ( text ) ; err != nil { t . Errorf ( " " , err ) } sheet , err := New ( " " , " " , src . Name ( ) , [ ] string { } , false , ) if err != nil { t . Errorf ( " " , err ) } outpath := path . Join ( os . TempDir ( ) , sheet . Title ) defer os . RemoveAll ( path . Join ( os . TempDir ( ) , " " ) ) err = sheet . Copy ( outpath ) if err != nil { t . Errorf ( " " , err ) } got , err := ioutil . ReadFile ( outpath ) if err != nil { t . Errorf ( " " , err ) } if string ( got ) != text { t . Errorf ( " " , text , got , ) } }
TestCopyDeep asserts that Copy correctly copies files at several levels of
depth
TestCopyDeep asserts that Copy correctly copies files at several levels of depth
// mock a cheatsheet file // mock a cheatsheet struct // compute the outfile's path // attempt to copy the cheatsheet // assert that the destination file contains the correct text