• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang utils.Fatalln函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/rafaeljusto/shelter/testing/utils.Fatalln函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatalln函数的具体用法?Golang Fatalln怎么用?Golang Fatalln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Fatalln函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: domainCacheTest

func domainCacheTest(database *mgo.Database, r *http.Request,
	requestContent, header string, domainCacheTestData []DomainCacheTestData) {

	mux := handy.NewHandy()

	h := new(handler.DomainHandler)
	mux.Handle("/domain/{fqdn}", func() handy.Handler {
		return h
	})

	for _, item := range domainCacheTestData {
		r.Header.Set(header, item.HeaderValue)

		if len(requestContent) > 0 {
			utils.BuildHTTPHeader(r, []byte(requestContent))
		} else {
			utils.BuildHTTPHeader(r, nil)
		}

		w := httptest.NewRecorder()
		mux.ServeHTTP(w, r)

		responseContent, err := ioutil.ReadAll(w.Body)
		if err != nil {
			utils.Fatalln("Error reading response body", err)
		}

		if w.Code != item.ExpectedHTTPStatus {
			utils.Fatalln(fmt.Sprintf("Error in %s test using %s [%s] "+
				"HTTP header. Expected HTTP status code %d and got %d",
				r.Method, header, item.HeaderValue, item.ExpectedHTTPStatus,
				w.Code), errors.New(string(responseContent)))
		}
	}
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:35,代码来源:rest_handler_domain.go


示例2: retrieveUnknownScan

func retrieveUnknownScan(database *mgo.Database, startedAt time.Time) {
	mux := handy.NewHandy()

	h := new(handler.ScanHandler)
	mux.Handle("/scan/{started-at}", func() handy.Handler {
		return h
	})

	r, err := http.NewRequest("GET", fmt.Sprintf("/scan/%s", startedAt.Add(-1*time.Millisecond).Format(time.RFC3339Nano)), nil)
	if err != nil {
		utils.Fatalln("Error creating the HTTP request", err)
	}
	utils.BuildHTTPHeader(r, nil)

	w := httptest.NewRecorder()
	mux.ServeHTTP(w, r)

	responseContent, err := ioutil.ReadAll(w.Body)
	if err != nil {
		utils.Fatalln("Error reading response body", err)
	}

	if w.Code != http.StatusNotFound {
		utils.Fatalln("Error retrieving unknown scan", errors.New(string(responseContent)))
	}
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:26,代码来源:rest_handler_scan.go


示例3: main

func main() {
	flag.Parse()

	var config ScanCollectorTestConfigFile
	err := utils.ReadConfigFile(configFilePath, &config)

	if err == utils.ErrConfigFileUndefined {
		fmt.Println(err.Error())
		fmt.Println("Usage:")
		flag.PrintDefaults()
		return

	} else if err != nil {
		utils.Fatalln("Error reading configuration file", err)
	}

	database, databaseSession, err := mongodb.Open(
		[]string{config.Database.URI},
		config.Database.Name,
		false, "", "",
	)
	if err != nil {
		utils.Fatalln("Error connecting the database", err)
	}
	defer databaseSession.Close()

	// Remove all data before starting the test. This is necessary because maybe in the last
	// test there was an error and the data wasn't removed from the database
	utils.ClearDatabase(database)

	domainWithErrors(config, database)
	domainWithNoErrors(config, database)

	utils.Println("SUCCESS!")
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:35,代码来源:scan_collector.go


示例4: deleteDomains

func deleteDomains(database *mgo.Database) {
	mux := handy.NewHandy()

	h := new(handler.DomainHandler)
	mux.Handle("/domain/{fqdn}", func() handy.Handler {
		return h
	})

	for i := 0; i < 100; i++ {
		r, err := http.NewRequest("DELETE", fmt.Sprintf("/domain/example%d.com.br.", i), nil)
		if err != nil {
			utils.Fatalln("Error creating the HTTP request", err)
		}
		utils.BuildHTTPHeader(r, nil)

		w := httptest.NewRecorder()
		mux.ServeHTTP(w, r)

		responseContent, err := ioutil.ReadAll(w.Body)
		if err != nil {
			utils.Fatalln("Error reading response body", err)
		}

		if w.Code != http.StatusNoContent {
			utils.Fatalln("Error removing domain", errors.New(string(responseContent)))
		}
	}
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:28,代码来源:rest_handler_domains.go


示例5: retrieveUnknownDomain

func retrieveUnknownDomain(database *mgo.Database) {
	mux := handy.NewHandy()

	h := new(handler.DomainHandler)
	mux.Handle("/domain/{fqdn}", func() handy.Handler {
		return h
	})

	r, err := http.NewRequest("GET", "/domain/example.com.br.", nil)
	if err != nil {
		utils.Fatalln("Error creating the HTTP request", err)
	}
	utils.BuildHTTPHeader(r, nil)

	w := httptest.NewRecorder()
	mux.ServeHTTP(w, r)

	responseContent, err := ioutil.ReadAll(w.Body)
	if err != nil {
		utils.Fatalln("Error reading response body", err)
	}

	if w.Code != http.StatusNotFound {
		utils.Fatalln("Error retrieving unknown domain", errors.New(string(responseContent)))
	}
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:26,代码来源:rest_handler_domain.go


示例6: createDomains

func createDomains() {
	var client http.Client

	url := ""
	if len(config.ShelterConfig.WebClient.Listeners) > 0 {
		url = fmt.Sprintf("http://%s:%d", config.ShelterConfig.WebClient.Listeners[0].IP,
			config.ShelterConfig.WebClient.Listeners[0].Port)
	}

	if len(url) == 0 {
		utils.Fatalln("There's no interface to connect to", nil)
	}

	var r *http.Request
	var err error

	for i := 0; i < 100; i++ {
		uri := fmt.Sprintf("/domain/example%d.com.br.", i)
		content := `{
  "Nameservers": [
    { "host": "a.dns.br." },
    { "host": "b.dns.br." }
  ],
  "Owners": [
    { "email": "[email protected]", "language": "pt-br" }
  ]
}`

		r, err = http.NewRequest("PUT", fmt.Sprintf("%s%s", url, uri),
			bytes.NewReader([]byte(content)))

		if err != nil {
			utils.Fatalln("Error creating the HTTP request", err)
		}

		utils.BuildHTTPHeader(r, []byte(content))

		response, err := client.Do(r)
		if err != nil {
			utils.Fatalln("Error sending request", err)
		}

		if response.StatusCode != http.StatusCreated {
			responseContent, err := ioutil.ReadAll(response.Body)

			if err == nil {
				utils.Fatalln(fmt.Sprintf("Expected HTTP status %d and got %d for method PUT and URI %s",
					http.StatusCreated, response.StatusCode, uri),
					errors.New(string(responseContent)),
				)
			} else {
				utils.Fatalln(fmt.Sprintf("Expected HTTP status %d and got %d for method PUT and URI %s",
					http.StatusCreated, response.StatusCode, uri), nil)
			}
		}
	}
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:57,代码来源:client_domains.go


示例7: retrieveScan

func retrieveScan(database *mgo.Database, startedAt time.Time) {
	mux := handy.NewHandy()

	h := new(handler.ScanHandler)
	mux.Handle("/scan/{started-at}", func() handy.Handler {
		return h
	})

	r, err := http.NewRequest("GET", fmt.Sprintf("/scan/%s", startedAt.Format(time.RFC3339Nano)), nil)
	if err != nil {
		utils.Fatalln("Error creating the HTTP request", err)
	}
	utils.BuildHTTPHeader(r, nil)

	w := httptest.NewRecorder()
	mux.ServeHTTP(w, r)

	responseContent, err := ioutil.ReadAll(w.Body)
	if err != nil {
		utils.Fatalln("Error reading response body", err)
	}

	if w.Code != http.StatusOK {
		utils.Fatalln("Error retrieving scan", errors.New(string(responseContent)))
	}

	if w.Header().Get("ETag") != "1" {
		utils.Fatalln("Not setting ETag in scan retrieve response", nil)
	}

	if len(w.Header().Get("Last-Modified")) == 0 {
		utils.Fatalln("Not setting Last-Modified in scan retrieve response", nil)
	}

	if h.Response.Status != "EXECUTED" {
		utils.Fatalln("Scan's status was not persisted correctly", nil)
	}

	if h.Response.DomainsScanned != 5000000 {
		utils.Fatalln("Scan's domains scanned information is wrong", nil)
	}

	if h.Response.DomainsWithDNSSECScanned != 250000 {
		utils.Fatalln("Scan's domains with DNSSEC scanned information is wrong", nil)
	}

	if h.Response.NameserverStatistics["OK"] != 4800000 ||
		h.Response.NameserverStatistics["TIMEOUT"] != 200000 {
		utils.Fatalln("Scan's nameserver statistics are wrong", nil)
	}

	if h.Response.DSStatistics["OK"] != 220000 ||
		h.Response.DSStatistics["EXPSIG"] != 30000 {
		utils.Fatalln("Scan's nameserver statistics are wrong", nil)
	}
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:56,代码来源:rest_handler_scan.go


示例8: main

func main() {
	flag.Parse()

	err := utils.ReadConfigFile(configFilePath, &config.ShelterConfig)

	if err == utils.ErrConfigFileUndefined {
		fmt.Println(err.Error())
		fmt.Println("Usage:")
		flag.PrintDefaults()
		return

	} else if err != nil {
		utils.Fatalln("Error reading configuration file", err)
	}

	database, databaseSession, err := mongodb.Open(
		config.ShelterConfig.Database.URIs,
		config.ShelterConfig.Database.Name,
		false, "", "",
	)

	if err != nil {
		utils.Fatalln("Error connecting the database", err)
	}
	defer databaseSession.Close()

	// If there was some problem in the last test, there could be some data in the
	// database, so let's clear it to don't affect this test. We avoid checking the error,
	// because if the collection does not exist yet, it will be created in the first
	// insert
	utils.ClearDatabase(database)

	invalidFQDN(database)
	createDomain(database)
	updateDomain(database)
	retrieveDomain(database)
	retrieveDomainMetadata(database)
	retrieveDomainIfModifiedSince(database)
	retrieveDomainIfUnmodifiedSince(database)
	retrieveDomainIfMatch(database)
	retrieveDomainIfNoneMatch(database)
	updateDomainIfModifiedSince(database)
	updateDomainIfUnmodifiedSince(database)
	updateDomainIfMatch(database)
	updateDomainIfNoneMatch(database)
	deleteDomainIfModifiedSince(database)
	deleteDomainIfUnmodifiedSince(database)
	deleteDomainIfMatch(database)
	deleteDomainIfNoneMatch(database)
	deleteDomain(database)
	retrieveUnknownDomain(database)

	utils.Println("SUCCESS!")
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:54,代码来源:rest_handler_domain.go


示例9: main

func main() {
	flag.Parse()

	var config DomainDAOTestConfigFile
	err := utils.ReadConfigFile(configFilePath, &config)

	if err == utils.ErrConfigFileUndefined {
		fmt.Println(err.Error())
		fmt.Println("Usage:")
		flag.PrintDefaults()
		return

	} else if err != nil {
		utils.Fatalln("Error reading configuration file", err)
	}

	database, databaseSession, err := mongodb.Open(
		[]string{config.Database.URI},
		config.Database.Name,
		false, "", "",
	)

	if err != nil {
		utils.Fatalln("Error connecting the database", err)
	}
	defer databaseSession.Close()

	domainDAO := dao.DomainDAO{
		Database: database,
	}

	// If there was some problem in the last test, there could be some data in the
	// database, so let's clear it to don't affect this test. We avoid checking the error,
	// because if the collection does not exist yet, it will be created in the first
	// insert
	domainDAO.RemoveAll()

	domainLifeCycle(domainDAO)
	domainsLifeCycle(domainDAO)
	domainUniqueFQDN(domainDAO)
	domainConcurrency(domainDAO)
	domainsPagination(domainDAO)
	domainsNotification(domainDAO)
	domainsExpand(domainDAO)
	domainFilter(domainDAO)

	// Domain DAO performance report is optional and only generated when the report file
	// path parameter is given
	if report {
		domainDAOPerformanceReport(config.Report.ReportFile, domainDAO)
	}

	utils.Println("SUCCESS!")
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:54,代码来源:dao_domain.go


示例10: main

func main() {
	flag.Parse()

	err := utils.ReadConfigFile(configFilePath, &config.ShelterConfig)

	if err == utils.ErrConfigFileUndefined {
		fmt.Println(err.Error())
		fmt.Println("Usage:")
		flag.PrintDefaults()
		return

	} else if err != nil {
		utils.Fatalln("Error reading configuration file", err)
	}

	database, databaseSession, err := mongodb.Open(
		config.ShelterConfig.Database.URIs,
		config.ShelterConfig.Database.Name,
		config.ShelterConfig.Database.Auth.Enabled,
		config.ShelterConfig.Database.Auth.Username,
		config.ShelterConfig.Database.Auth.Password,
	)

	if err != nil {
		utils.Fatalln("Error connecting the database", err)
	}
	defer databaseSession.Close()

	// If there was some problem in the last test, there could be some data in the database,
	// so let's clear it to don't affect this test. We avoid checking the error, because if
	// the collection does not exist yet, it will be created in the first insert
	utils.ClearDatabase(database)

	messageChannel, errorChannel, err := utils.StartMailServer(config.ShelterConfig.Notification.SMTPServer.Port)
	if err != nil {
		utils.Fatalln("Error starting the mail server", err)
	}

	domainDAO := dao.DomainDAO{
		Database: database,
	}

	templateName := createTemplateFile()
	defer removeTemplateFile(templateName)

	simpleNotification(domainDAO, templateName, messageChannel, errorChannel)

	utils.Println("SUCCESS!")
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:49,代码来源:notification.go


示例11: restActionReport

func restActionReport(numberOfItems int,
	content []byte,
	requestBuilder func(int) (*http.Request, error),
	expectedStatus int,
	action string) string {

	var client http.Client

	totalDuration, domainsPerSecond := calculateRESTDurations(func() {
		for i := 0; i < numberOfItems; i++ {
			r, err := requestBuilder(i)
			if err != nil {
				utils.Fatalln("Error creating the HTTP request", err)
			}

			utils.BuildHTTPHeader(r, content)

			response, err := client.Do(r)
			if err != nil {
				utils.Fatalln(fmt.Sprintf("Error detected when sending request for action %s"+
					" and URI \"%s\"", action, r.URL.RequestURI()), err)
			}

			_, err = ioutil.ReadAll(response.Body)
			if err != nil {
				utils.Fatalln(fmt.Sprintf("Error detected when reading the response body for action %s"+
					" and URI \"%s\"", action, r.URL.RequestURI()), err)
			}
			response.Body.Close()

			if response.StatusCode != expectedStatus {
				utils.Fatalln(fmt.Sprintf("Error with the domain object in the action %s. "+
					"Expected HTTP status %d and got %d",
					action, expectedStatus, response.StatusCode), nil)
			}
		}
	}, numberOfItems)

	var memStats runtime.MemStats
	runtime.ReadMemStats(&memStats)

	return fmt.Sprintf("% -8d | %-9s | %16s | %4d | %14.2f\n",
		numberOfItems,
		action,
		time.Duration(int64(totalDuration)).String(),
		domainsPerSecond,
		float64(memStats.Alloc)/float64(MB),
	)
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:49,代码来源:rest.go


示例12: updateDomainIfNoneMatch

func updateDomainIfNoneMatch(database *mgo.Database) {
	requestContent := `{
      "Nameservers": [
        { "host": "ns1.example.com.br.", "ipv4": "127.0.0.1" },
        { "host": "ns3.example.com.br.", "ipv6": "::1" }
      ],
      "Owners": [
        { "email": "[email protected]", "language": "en-us" }
      ]
    }`

	r, err := http.NewRequest("PUT", "/domain/example.com.br.", strings.NewReader(requestContent))
	if err != nil {
		utils.Fatalln("Error creating the HTTP request", err)
	}

	domainCacheTest(database, r, requestContent, "If-None-Match", []DomainCacheTestData{
		{
			HeaderValue:        "3",
			ExpectedHTTPStatus: http.StatusPreconditionFailed,
		},
		{
			HeaderValue:        "abcdef",
			ExpectedHTTPStatus: http.StatusNoContent,
		},
	})
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:27,代码来源:rest_handler_domain.go


示例13: main

func main() {
	flag.Parse()

	var clientConfig ClientDomainVerificationTestConfigFile
	err := utils.ReadConfigFile(configFilePath, &clientConfig)
	config.ShelterConfig = clientConfig.Config

	if err == utils.ErrConfigFileUndefined {
		fmt.Println(err.Error())
		fmt.Println("Usage:")
		flag.PrintDefaults()
		return

	} else if err != nil {
		utils.Fatalln("Error reading configuration file", err)
	}

	utils.StartDNSServer(clientConfig.DNSServerPort, clientConfig.Scan.UDPMaxSize)
	finishRESTServer := utils.StartRESTServer()
	defer finishRESTServer()
	utils.StartWebClient()

	scanDomain()
	queryDomain()

	utils.Println("SUCCESS!")
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:27,代码来源:client_domain_verification.go


示例14: generateAndSaveDomain

// Function to mock a domain
func generateAndSaveDomain(fqdn string, domainDAO dao.DomainDAO, language string) {
	lastOKAt := time.Now().Add(time.Duration(-config.ShelterConfig.Notification.NameserverErrorAlertDays*24) * time.Hour)
	owner, _ := mail.ParseAddress("[email protected]")

	domain := model.Domain{
		FQDN: fqdn,
		Nameservers: []model.Nameserver{
			{
				Host:       fmt.Sprintf("ns1.%s", fqdn),
				IPv4:       net.ParseIP("127.0.0.1"),
				LastStatus: model.NameserverStatusServerFailure,
				LastOKAt:   lastOKAt,
			},
		},
		Owners: []model.Owner{
			{
				Email:    owner,
				Language: language,
			},
		},
	}

	if err := domainDAO.Save(&domain); err != nil {
		utils.Fatalln(fmt.Sprintf("Fail to save domain %s", domain.FQDN), err)
	}
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:27,代码来源:notification.go


示例15: main

func main() {
	flag.Parse()

	var config ScanQuerierTestConfigFile
	err := utils.ReadConfigFile(configFilePath, &config)

	if err == utils.ErrConfigFileUndefined {
		fmt.Println(err.Error())
		fmt.Println("Usage:")
		flag.PrintDefaults()
		return

	} else if err != nil {
		utils.Fatalln("Error reading configuration file", err)
	}

	utils.StartDNSServer(config.Server.Port, config.Scan.UDPMaxSize)

	domainWithNoDNSErrors(config)
	domainWithNoDNSSECErrors(config)
	domainDNSTimeout(config)
	domainDNSUnknownHost(config)

	// Scan querier performance report is optional and only generated when the report file
	// path parameter is given
	if report {
		scanQuerierReport(config)
	}

	if inputReport {
		inputScanReport(config)
	}

	utils.Println("SUCCESS!")
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:35,代码来源:scan_querier.go


示例16: createScan

func createScan(database *mgo.Database) time.Time {
	scan := model.Scan{
		Status:                   model.ScanStatusExecuted,
		StartedAt:                time.Now().Add(-60 * time.Minute),
		FinishedAt:               time.Now().Add(-10 * time.Minute),
		DomainsScanned:           5000000,
		DomainsWithDNSSECScanned: 250000,
		NameserverStatistics: map[string]uint64{
			"OK":      4800000,
			"TIMEOUT": 200000,
		},
		DSStatistics: map[string]uint64{
			"OK":     220000,
			"EXPSIG": 30000,
		},
	}

	scanDAO := dao.ScanDAO{
		Database: database,
	}

	if err := scanDAO.Save(&scan); err != nil {
		utils.Fatalln("Error creating scan", err)
	}

	return scan.StartedAt
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:27,代码来源:rest_handler_scan.go


示例17: retrieveScansIfNoneMatch

func retrieveScansIfNoneMatch(database *mgo.Database) {
	mux := handy.NewHandy()

	h := new(handler.ScansHandler)
	mux.Handle("/scans", func() handy.Handler {
		return h
	})

	r, err := http.NewRequest("GET", "/scans", nil)
	if err != nil {
		utils.Fatalln("Error creating the HTTP request", err)
	}
	utils.BuildHTTPHeader(r, nil)

	w := httptest.NewRecorder()
	mux.ServeHTTP(w, r)

	scansCacheTest(database, r, "If-None-Match", []ScansCacheTestData{
		{
			HeaderValue:        w.Header().Get("ETag"),
			ExpectedHTTPStatus: http.StatusNotModified,
		},
		{
			HeaderValue:        w.Header().Get("ETag") + "x",
			ExpectedHTTPStatus: http.StatusOK,
		},
	})
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:28,代码来源:rest_handler_scans.go


示例18: createScans

func createScans(database *mgo.Database) {
	scanDAO := dao.ScanDAO{
		Database: database,
	}

	for i := 0; i < 100; i++ {
		scan := model.Scan{
			Status:                   model.ScanStatusExecuted,
			StartedAt:                time.Now().Add(time.Duration(-i*2) * time.Minute),
			FinishedAt:               time.Now().Add(time.Duration(-i) * time.Minute),
			DomainsScanned:           5000000,
			DomainsWithDNSSECScanned: 250000,
			NameserverStatistics: map[string]uint64{
				"OK":      4800000,
				"TIMEOUT": 200000,
			},
			DSStatistics: map[string]uint64{
				"OK":     220000,
				"EXPSIG": 30000,
			},
		}

		if err := scanDAO.Save(&scan); err != nil {
			utils.Fatalln("Error creating scan", err)
		}
	}
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:27,代码来源:client_scans.go


示例19: updateDomainIfUnmodifiedSince

func updateDomainIfUnmodifiedSince(database *mgo.Database) {
	requestContent := `{
      "Nameservers": [
        { "host": "ns1.example.com.br.", "ipv4": "127.0.0.1" },
        { "host": "ns3.example.com.br.", "ipv6": "::1" }
      ],
      "Owners": [
        { "email": "[email protected]", "language": "pt-br" }
      ]
    }`

	r, err := http.NewRequest("PUT", "/domain/example.com.br.", strings.NewReader(requestContent))
	if err != nil {
		utils.Fatalln("Error creating the HTTP request", err)
	}

	domainCacheTest(database, r, requestContent, "If-Unmodified-Since", []DomainCacheTestData{
		{
			HeaderValue:        "abcdef",
			ExpectedHTTPStatus: http.StatusBadRequest,
		},
		{
			HeaderValue:        time.Now().Add(-10 * time.Second).UTC().Format(time.RFC1123),
			ExpectedHTTPStatus: http.StatusPreconditionFailed,
		},
	})
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:27,代码来源:rest_handler_domain.go


示例20: removeDomains

func removeDomains() {
	var client http.Client

	url := ""
	if len(config.ShelterConfig.WebClient.Listeners) > 0 {
		url = fmt.Sprintf("http://%s:%d", config.ShelterConfig.WebClient.Listeners[0].IP,
			config.ShelterConfig.WebClient.Listeners[0].Port)
	}

	if len(url) == 0 {
		utils.Fatalln("There's no interface to connect to", nil)
	}

	var r *http.Request
	var err error

	for i := 0; i < 100; i++ {
		uri := fmt.Sprintf("/domain/example%d.com.br.", i)

		r, err = http.NewRequest("DELETE", fmt.Sprintf("%s%s", url, uri), nil)

		if err != nil {
			utils.Fatalln("Error creating the HTTP request", err)
		}

		utils.BuildHTTPHeader(r, nil)

		response, err := client.Do(r)
		if err != nil {
			utils.Fatalln("Error sending request", err)
		}

		if response.StatusCode != http.StatusNoContent {
			responseContent, err := ioutil.ReadAll(response.Body)

			if err == nil {
				utils.Fatalln(fmt.Sprintf("Expected HTTP status %d and got %d for method DELETE and URI %s",
					http.StatusCreated, response.StatusCode, uri),
					errors.New(string(responseContent)),
				)
			} else {
				utils.Fatalln(fmt.Sprintf("Expected HTTP status %d and got %d for method DELETE and URI %s",
					http.StatusCreated, response.StatusCode, uri), nil)
			}
		}
	}
}
开发者ID:rafaeljusto,项目名称:shelter,代码行数:47,代码来源:client_domains.go



注:本文中的github.com/rafaeljusto/shelter/testing/utils.Fatalln函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang xpc.Dict函数代码示例发布时间:2022-05-28
下一篇:
Golang utils.BuildHTTPHeader函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap