func TestServerGetFiles(t *testing.T) {
	ctx := context.Background()
	log := logtest.DiscardLogger
	db := new(db.Database)
	e := embeddedData(t)
	f := main.Flags{
		HTTPSPort: 8000, // not actually used, overridden by httptest
	}
	s, err := f.CreateServer(ctx, log, db, e)
	if err != nil {
		t.Fatalf("unwanted create server error: %v", err)
	}
	getHandler := s.HTTPSServer.Handler
	ts := httptest.NewTLSServer(getHandler)
	defer ts.Close()
	c := ts.Client()
	getFilePaths := []string{
		"/wasm_exec.js", "/selene-bananas.wasm", "/robots.txt", "/favicon.png", "/favicon.ico", "/LICENSE", // static files
		"/", "/manifest.json", "/serviceWorker.js", "/favicon.svg", "/network_check.html", // templates
	}
	for i, p := range getFilePaths {
		url := ts.URL + p
		res, err := c.Get(url)
		switch {
		case err != nil:
			t.Errorf("Test %v: unwanted server get error: %v", i, err)
		case res.StatusCode != 200:
			body, err := io.ReadAll(res.Body)
			res.Body.Close()
			if err != nil {
				t.Errorf("reading error response body: %v", err)
			}
			t.Errorf("Test %v: wanted 200 code, got %v (%v): %s", i, res.StatusCode, res.Status, body)
		}
	}
}
// TestServerGet ensures the server handles get responses for files and templates.
// This integration test is SLOW because it starts a test server.
TestServerGet ensures the server handles get responses for files and templates.
This integration test is SLOW because it starts a test server.
// TestServerGet ensures the server handles get responses for files and templates . // This integration test is SLOW because it starts a test server .
func TestServerGetFiles(t *testing.T) {
	ctx := context.Background()
	log := logtest.DiscardLogger
	db := new(db.Database)
	e := embeddedData(t)
	f := main.Flags{
		HTTPSPort: 8000, 
	}
	s, err := f.CreateServer(ctx, log, db, e)
	if err != nil {
		t.Fatalf("unwanted create server error: %v", err)
	}
	getHandler := s.HTTPSServer.Handler
	ts := httptest.NewTLSServer(getHandler)
	defer ts.Close()
	c := ts.Client()
	getFilePaths := []string{
		"/wasm_exec.js", "/selene-bananas.wasm", "/robots.txt", "/favicon.png", "/favicon.ico", "/LICENSE", 
		"/", "/manifest.json", "/serviceWorker.js", "/favicon.svg", "/network_check.html", 
	}
	for i, p := range getFilePaths {
		url := ts.URL + p
		res, err := c.Get(url)
		switch {
		case err != nil:
			t.Errorf("Test %v: unwanted server get error: %v", i, err)
		case res.StatusCode != 200:
			body, err := io.ReadAll(res.Body)
			res.Body.Close()
			if err != nil {
				t.Errorf("reading error response body: %v", err)
			}
			t.Errorf("Test %v: wanted 200 code, got %v (%v): %s", i, res.StatusCode, res.Status, body)
		}
	}
}
func TestServerGetFiles ( t * testing . T ) { ctx := context . Background ( ) log := logtest . DiscardLogger db := new ( db . Database ) e := embeddedData ( t ) f := main . Flags { HTTPSPort : 8000 , } s , err := f . CreateServer ( ctx , log , db , e ) if err != nil { t . Fatalf ( " " , err ) } getHandler := s . HTTPSServer . Handler ts := httptest . NewTLSServer ( getHandler ) defer ts . Close ( ) c := ts . Client ( ) getFilePaths := [ ] string { " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , } for i , p := range getFilePaths { url := ts . URL + p res , err := c . Get ( url ) switch { case err != nil : t . Errorf ( " " , i , err ) case res . StatusCode != 200 : body , err := io . ReadAll ( res . Body ) res . Body . Close ( ) if err != nil { t . Errorf ( " " , err ) } t . Errorf ( " " , i , res . StatusCode , res . Status , body ) } } }
TestServerGet ensures the server handles get responses for files and templates.
TestServerGet ensures the server handles get responses for files and templates .
// not actually used, overridden by httptest // static files // templates