dynamische IP für die vorherige Tests
This commit is contained in:
@@ -1,7 +1,21 @@
|
||||
import axios from "axios";
|
||||
import os from "os"; // Modul zum Ermitteln der IP-Adresse
|
||||
|
||||
// Basis-URL des Servers
|
||||
const BASE_URL = "http://10.10.0.70:3000/api/gisStationsMeasurements";
|
||||
// Dynamische Ermittlung der IP-Adresse des Rechners
|
||||
function getLocalIPAddress() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
for (const name of Object.keys(interfaces)) {
|
||||
for (const iface of interfaces[name]) {
|
||||
if (iface.family === "IPv4" && !iface.internal) {
|
||||
return iface.address; // Rückgabe der IPv4-Adresse
|
||||
}
|
||||
}
|
||||
}
|
||||
return "localhost"; // Fallback zu localhost
|
||||
}
|
||||
|
||||
// Basis-URL dynamisch erstellen
|
||||
const BASE_URL = `http://${getLocalIPAddress()}:3000/api/gisStationsMeasurements`;
|
||||
|
||||
describe("Echte API-Integrationstests für gisStationsMeasurements", () => {
|
||||
// Test 1: Erfolgreiche Anfrage mit gültigen Parametern
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
import axios from "axios";
|
||||
import os from "os"; // Modul zum Ermitteln der IP-Adresse
|
||||
|
||||
// Basis-URL des Servers
|
||||
const BASE_URL = "http://10.10.0.70:3000/api/gisStationsStaticDistrict";
|
||||
// Dynamische Ermittlung der IP-Adresse des Rechners
|
||||
function getLocalIPAddress() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
for (const name of Object.keys(interfaces)) {
|
||||
for (const iface of interfaces[name]) {
|
||||
if (iface.family === "IPv4" && !iface.internal) {
|
||||
return iface.address; // Rückgabe der IPv4-Adresse
|
||||
}
|
||||
}
|
||||
}
|
||||
return "localhost"; // Fallback zu localhost
|
||||
}
|
||||
|
||||
// Basis-URL dynamisch erstellen
|
||||
const BASE_URL = `http://${getLocalIPAddress()}:3000/api/gisStationsStaticDistrict`;
|
||||
|
||||
describe("Echte API-Integrationstests für gisStationsStaticDistrict", () => {
|
||||
// Test 1: Erfolgreiche Anfrage mit gültigen Parametern
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
import axios from "axios";
|
||||
import os from "os"; // Modul zum Ermitteln der IP-Adresse
|
||||
|
||||
// Basis-URL des Servers
|
||||
const BASE_URL = "http://10.10.0.70:3000/api/gisStationsStatusDistrict";
|
||||
// Dynamische Ermittlung der IP-Adresse des Rechners
|
||||
function getLocalIPAddress() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
for (const name of Object.keys(interfaces)) {
|
||||
for (const iface of interfaces[name]) {
|
||||
if (iface.family === "IPv4" && !iface.internal) {
|
||||
return iface.address; // Rückgabe der IPv4-Adresse
|
||||
}
|
||||
}
|
||||
}
|
||||
return "localhost"; // Fallback zu localhost
|
||||
}
|
||||
|
||||
describe("Echte API-Integrationstests", () => {
|
||||
// Basis-URL dynamisch erstellen
|
||||
const BASE_URL = `http://${getLocalIPAddress()}:3000/api/gisStationsStatusDistrict`;
|
||||
|
||||
describe("Echte API-Integrationstests für gisStationsStatusDistrict", () => {
|
||||
// Test 1: Erfolgreiche Anfrage mit gültigen Parametern
|
||||
it("gibt JSON-Daten zurück, wenn gültige Parameter übergeben werden", async () => {
|
||||
const params = {
|
||||
m: "12",
|
||||
u: "484",
|
||||
m: "12", // Beispiel für idMap
|
||||
u: "484", // Beispiel für idUser
|
||||
};
|
||||
|
||||
// Echte Anfrage an den Server senden
|
||||
const response = await axios.get(BASE_URL, { params });
|
||||
|
||||
// Antwortstatus prüfen
|
||||
// Statuscode prüfen
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
// Antwortdaten prüfen
|
||||
@@ -31,6 +46,7 @@ describe("Echte API-Integrationstests", () => {
|
||||
expect(item).toHaveProperty("Icon");
|
||||
});
|
||||
|
||||
// Test 2: Fehler bei fehlenden Parametern
|
||||
it("gibt einen Fehler zurück, wenn Parameter fehlen", async () => {
|
||||
try {
|
||||
// Anfrage ohne Parameter
|
||||
@@ -42,11 +58,12 @@ describe("Echte API-Integrationstests", () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Test 3: Fehler bei ungültigen Parametern
|
||||
it("gibt einen Serverfehler zurück, wenn ungültige Parameter verwendet werden", async () => {
|
||||
try {
|
||||
const params = {
|
||||
m: "invalid",
|
||||
u: "invalid",
|
||||
m: "invalid", // Ungültige idMap
|
||||
u: "invalid", // Ungültige idUser
|
||||
};
|
||||
|
||||
await axios.get(BASE_URL, { params });
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
import axios from "axios";
|
||||
import os from "os";
|
||||
|
||||
// Basis-URL des Servers
|
||||
const BASE_URL = "http://10.10.0.70:3000/api/gisSystemStatic";
|
||||
// Dynamische IP-Adresse ermitteln
|
||||
function getLocalIPAddress() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
for (const name of Object.keys(interfaces)) {
|
||||
for (const iface of interfaces[name]) {
|
||||
if (iface.family === "IPv4" && !iface.internal) {
|
||||
return iface.address; // IPv4-Adresse zurückgeben
|
||||
}
|
||||
}
|
||||
}
|
||||
return "localhost"; // Fallback zu localhost
|
||||
}
|
||||
|
||||
// Dynamische Basis-URL
|
||||
const BASE_URL = `http://${getLocalIPAddress()}:3000/api/gisSystemStatic`;
|
||||
//http://localhost:3000/api/gisSystemStatic
|
||||
describe("Echte API-Integrationstests für gisSystemStatic", () => {
|
||||
// Test 1: Erfolgreiche Anfrage mit gültigen Parametern
|
||||
it("gibt JSON-Daten zurück, wenn gültige Parameter übergeben werden", async () => {
|
||||
@@ -14,8 +28,8 @@ describe("Echte API-Integrationstests für gisSystemStatic", () => {
|
||||
// Echte Anfrage an den Server senden
|
||||
const response = await axios.get(BASE_URL, { params });
|
||||
|
||||
// Debugging der Header
|
||||
console.log(response.headers);
|
||||
// Header sicher loggen
|
||||
console.log("Content-Type:", response.headers["content-type"]);
|
||||
|
||||
// Statuscode prüfen
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
Reference in New Issue
Block a user