def test_testName(self): color.blue("test here baby") targetFileContent = """package main func absByRel(relFilePath, currentFolderPwd string) (absPath string) { } func main() { targetFileOrFolderAbsOrRel, _ := my.GetArgBashTerminal(1) } """ position = 22 result = generateTestFileNameForGoTest.createTestFileContentBySourceFileTargetAndPosition(targetFileContent, position) expected = """package main import ( "my" "testing" ) func Test_absByRel(t *testing.T) { var ( relFilePath string currentFolderPwd string absPath string absPath_expected string ) absPath = absByRel(relFilePath,currentFolderPwd) expectedJson_absPath := `` my.FromJson(expectedJson_absPath, &absPath_expected) my.Test(absPath, absPath_expected, t) }""" assertMy.equals(result, expected)
def test_testName(self): color.blue("test here baby") targetFileContent = """package elit import ( "my" "testing" ) func doAllForMiByUrl(url string, expected menuItem, t *testing.T) (res1 int, res2 int) { actual := MiByUrl(url) my.Test(actual, expected, t) } func doAllForAddAlt(mi menuItem, expectedAlt string, t *testing.T) { miAddAlt(&mi) actual := mi.alt my.Test(actual, expectedAlt, t) } func doAllFor_fullHtmlUrl(mi *menuItem, expectedFullHtmlUrl string, t *testing.T) { actual := fullHtmlUrl(mi) my.Test(actual, expectedFullHtmlUrl, t) } func TestMiByUrl(t *testing.T) { SetMenu() url := "Glavnaja" expected := menu[0] doAllForMiByUrl(url, expected, t) } func TestMiByUrlSubMenu(t *testing.T) { SetMenu() url := "KozyrkiNavesy" expected := menu[1].subMenu[1] doAllForMiByUrl(url, expected, t) } func TestAddAlt(t *testing.T) { SetMenu() mi := menu[0] doAllForAddAlt(mi, "Главная - ТСК 'ЭЛИТСТРОЙ' Тверь", t) } func TestFullHtmlUrl(t *testing.T) { SetMenu() mi := menu[0] doAllFor_fullHtmlUrl(&mi, "/Content/fotos2/Glavnaja", t) } // func TestHtmlFileUrl(t *testing.T) { // } func TestFullGalleryUrl(t *testing.T) { SetMenu() mi := MiByUrl("PerilaOograzhdenijaIzNerzhavejuwejStali") my.Test(galleryUrl(&mi), "/Kovka/Gallereja/PerilaOograzhdenijaIzNerzhavejuwejStali", t) } func Test_photosRelPath(t *testing.T) { SetMenu() mi := MiByUrl("PerilaOograzhdenijaIzNerzhavejuwejStali") my.Test(mi.photosRelPath(), "./Content/fotos2/PerilaOograzhdenijaIzNerzhavejuwejStali", t) } func Test_photoHtmlPath(t *testing.T) { SetMenu() mi := MiByUrl("PerilaOograzhdenijaIzNerzhavejuwejStali") my.Test(mi.photoHtmlPath("1.jpg"), "/Content/fotos2/PerilaOograzhdenijaIzNerzhavejuwejStali/1.jpg", t) } func Test_isThumb(t *testing.T) { my.Test(isThumb("10_resize.jpg"), true, t) } func Test_isThumbFalse(t *testing.T) { my.Test(isThumb("10.jpg"), false, t) } func Test_thumbFileNameToBigFileName(t *testing.T) { my.Test(thumbFileNameToBigFileName("10_resize.jpg"), "10.jpg", t) } func Test_fotoListByMenuItemUrl(t *testing.T) { my.Test(fotoListByMenuItemUrl("PerilaOograzhdenijaIzNerzhavejuwejStali"), "./Content/fotos2/PerilaOograzhdenijaIzNerzhavejuwejStali", t) } func Test_fileNameListToFotoList(t *testing.T) { my.Test(fileNameListToFotoList([]string{"10_resize.jpg", "10.jpg"}), FotoList{foto{Thumb: "10_resize.jpg", BigFoto: "10.jpg"}}, t) } func Test_sortFileNames(t *testing.T) { fileNames := []string{"10_resize.jpg", "10.jpg", "1_resize.jpg", "1.jpg"} expected := []string{"1_resize.jpg", "1.jpg", "10_resize.jpg", "10.jpg"} my.Test(sortFileNames(fileNames), expected, t) } """ position = 56 result = generateTestFileNameForGoTest.createTestFileContentBySourceFileTargetAndPosition(targetFileContent, position) expected = """package elit import ( "my" "testing" ) func Test_doAllForMiByUrl(t *testing.T) { var ( url string expected menuItem t *testing.T res1 int res2 int res1_expected int res2_expected int ) res1,res2 = doAllForMiByUrl(url,expected,t) expectedJson_res1 := `` my.FromJson(expectedJson_res1, &res1_expected) my.Test(res1, res1_expected, t) expectedJson_res2 := `` my.FromJson(expectedJson_res2, &res2_expected) my.Test(res2, res2_expected, t) }""" assertMy.equals(result, expected)
def test_testName(self): color.blue("test here baby") targetFileContent = """package model import ( "fmt" "github.com/go-shadow/moment" "html/template" "my" // "time" ) type YearLocals struct { Weeks []template.HTML Title, Descr string H1 template.HTML } func WrapBigBold(str string) string { return fmt.Sprintf("<b><big>%s</big></b>", str) } // 1)29.12-04.01, 2)05.01-11.01, 3)12.01-18.01, 4)19.01-25.01, 5)26.01-01.02, 6)02.02-08.02, 7)09.02-15.02, 8)16.02-22.02, 9)23.02-01.03, 10)02.03-08.03, 11)09.03-15.03, 12)16.03-22.03, 13)23.03-29.03, 14)30.03-05.04, 15)06.04-12.04, 16)13.04-19.04, 17)20.04-26.04, 18)27.04-03.05, 19)04.05-10.05, 20)11.05-17.05, 21)18.05-24.05, 22)25.05-31.05, 23)01.06-07.06, 24)08.06-14.06, 25)15.06-21.06, 26)22.06-28.06, 27)29.06-05.07, 28)06.07-12.07, 29)13.07-19.07, 30)20.07-26.07, 31)27.07-02.08, 32)03.08-09.08, 33)10.08-16.08, 34)17.08-23.08, 35)24.08-30.08, 36)31.08-06.09, 37)07.09-13.09, 38)14.09-20.09, 39)21.09-27.09, 40)28.09-04.10, 41)05.10-11.10, 42)12.10-18.10, 43)19.10-25.10, 44)26.10-01.11, 45)02.11-08.11, 46)09.11-15.11, 47)16.11-22.11, 48)23.11-29.11, 49)30.11-06.12, 50)07.12-13.12, 51)14.12-20.12, 52)21.12-27.12, 53)28.12-03.01, func GetYearLocals(yearStr string) (yearLocals *YearLocals, currentWeekAnchor template.HTML) { year := my.StrToInt(yearStr) from, to := firstWeekOfYear(year) // first week of next year fromNext, _ := firstWeekOfYear(year + 1) var weeks []template.HTML weekCounter := 1 var descr string for { // current week: strWeek := weekToStr(toRuString(from), toRuString(to)) title := titleByYearAndWeekNumber(year, weekCounter) linkUrl := yearWeekLinkUrl(year, weekCounter) a := weekAnchorByYearWeekNumberAndTextInsideAnchor(year, weekCounter, strWeek) if WeekIsCurrent(from, to) { a = WrapBigBold(a) currentWeekAnchor = template.HTML(weekAnchorByYearWeekNumberAndTextInsideAnchor(year, weekCounter, fmt.Sprintf("%d-я", weekCounter))) } weeks = append(weeks, template.HTML(a)) fromShort := toStringForVeryShortDescr(from) toShort := toStringForVeryShortDescr(to) descrItem := fmt.Sprintf("%d)%s-%s, ", weekCounter, fromShort, toShort) descr += descrItem my.P(a) // next week weekCounter++ from.AddDays(daysInWeek) to.AddDays(daysInWeek) // if we archived next year - enough if from.Diff(fromNext, "seconds") == 0 { break } } title := fmt.Sprintf(`недели %d года`, year) yearLocals = &YearLocals{ Weeks: weeks, Title: title, H1: template.HTML(title), Descr: my.Trim(descr), } return } func yearWeekLinkUrl(year, week int) string { return fmt.Sprintf("/%d/%d", year, week) } // func descriptionYear(year) func OneTwoFiftyTwoAnchors() (html template.HTML) { today := moment.New() yearNow := today.Year() const lastWeek = 52 targetFirstWeeks = []int{1, 2} totalHtmlStr = "" for _, weekNumber := range targetFirstWeeks { strAnchor := generateWeekAnchorForSiteHead(weekNumber) } totalHtmlStr += "..." totalHtmlStr += generateWeekAnchorForSiteHead(lastWeek) return totalHtmlStr } """ position = 2618 result = generateTestFileNameForGoTest.createTestFileContentBySourceFileTargetAndPosition(targetFileContent, position) expected = """package model import ( "my" "testing" ) func Test_OneTwoFiftyTwoAnchors(t *testing.T) { var ( html template.HTML html_expected template.HTML ) html = OneTwoFiftyTwoAnchors() expectedJson_html := `` my.FromJson(expectedJson_html, &html_expected) my.Test(html, html_expected, t) }""" assertMy.equals(result, expected)
def test_testName(self): color.blue("test here baby") targetFileContent = """package main import ( "github.com/go-martini/martini" "my" "my/mart" "net/http" "runly/db" ) // Request URL:http://localhost:3000/ajaxSearchInYoutubeApi?searchInput=Jarren%20Benton%20-%20Go%20Off%20feat.%20SwizZz%20&%20Hopsin%20(Official%20Video) // func searchInputParam(r *http.Request) (paramValue string) { paramValue = mart.GetQueryParam(r, "searchInput") return paramValue } func addSearchRoutes(m *martini.ClassicMartini) { m.Get("/ajaxSearchInYoutubeApi", func(w http.ResponseWriter, r *http.Request) { searchInput := searchInputParam(r) my.P("searchInput") my.P(searchInput) results, err := db.SearchYoutubeByKey(searchInput) my.FLI(err) my.P("results") my.P(results) ren.JSON(w, http.StatusOK, results) }) // http://localhost:3000/searchClipsWithClicks_route?searchInput=Jarren%20Benton%20-%20Go%20Off%20feat.%20SwizZz%20&%20Hopsin%20(Official%20Video) m.Get("/searchClipsWithClicks_route", func(w http.ResponseWriter, r *http.Request) { searchInput := searchInputParam(r) my.P("searchInput") my.P(searchInput) }) } """ position = 275 result = generateTestFileNameForGoTest.createTestFileContentBySourceFileTargetAndPosition(targetFileContent, position) expected = """package main import ( "my" "testing" ) func Test_searchInputParam(t *testing.T) { var ( r *http.Request paramValue string paramValue_expected string ) paramValue = searchInputParam(r) expectedJson_paramValue := `` my.FromJson(expectedJson_paramValue, ¶mValue_expected) my.Test(paramValue, paramValue_expected, t) }""" assertMy.equals(result, expected)